0

i have 4 fields (Name , age, class, subject) in one index (Student_Entry) and i want to add total events but i want to exclude those events who has any value in subject field.

I tried the below two ways

index=Student_Entry   Subject !=* | stats count by event
index=Student_Entry   NOT Subject= * | stats count by event
Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100

3 Answers3

2

The NOT and != operators are similar, but not equivalent. NOT will return events with no value in the Subject field, whereas != will not. In your case, use !=. See https://docs.splunk.com/Documentation/Splunk/8.0.4/Search/NOTexpressions

stats count by event does nothing because there is no field called 'event'. To count events, just use stats count.

RichG
  • 9,063
  • 2
  • 18
  • 29
0

It looks like you were right using index=Student_Entry Subject !=*

Then you can add only - | stats count

Gil Kor
  • 314
  • 1
  • 2
  • 9
0

You can do it this way, too:

index=Student_Entry
| where isnull(subject)
| stats count
warren
  • 32,620
  • 21
  • 85
  • 124