Splunk Search

show count as zero if no data found

royimad
Builder

Hello,
I have a search like this: sourcetype="mysource" | stats count by field
I need to show zero if the field doesn't exist in the result how to do that?

Thanks,

Tags (1)
0 Karma
1 Solution

lukejadamec
Super Champion

Use fillnull:

sourcetype="mysource" | fillnull value="0" field | stats count by field

View solution in original post

lukejadamec
Super Champion

Use fillnull:

sourcetype="mysource" | fillnull value="0" field | stats count by field

sowings
Splunk Employee
Splunk Employee

"Original Poster" == the person who asked the question.

0 Karma

lukejadamec
Super Champion

? fillnull will add the field with a zero value if it does not exist, and add a zero if it has no value. That is what OP wanted. What does OP stand for?

0 Karma

sowings
Splunk Employee
Splunk Employee

The search you've provided will fill "field" with 0 everywhere, then count the occurrences by the value, where the count of "value=0" will represent the number of events where the field was empty. I'm not quite sure what the OP wanted....

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...