我在一个索引(Student_Entry(中有4个字段(Name
,age
,class
,subject
(,我想添加事件总数,但我想排除那些在主题字段中具有任何值的事件。
我尝试了以下两种方法
index=Student_Entry Subject !=* | stats count by event
index=Student_Entry NOT Subject= * | stats count by event
NOT
和!=
运算符相似,但不等效。NOT
将返回"主题"字段中没有值的事件,而!=
不会。 在您的情况下,请使用!=
. 请参阅 https://docs.splunk.com/Documentation/Splunk/8.0.4/Search/NOTexpressions
stats count by event
什么都不做,因为没有称为"事件"的字段。 要计算事件,只需使用stats count
.
看起来你用index=Student_Entry Subject !=*
是对的然后你只能添加 -| stats count
你也可以这样做:
index=Student_Entry
| where isnull(subject)
| stats count