Splunk Search

Add zero value when using _time field

whitefang1726
Path Finder

When using stats count on searches, it does not show zero values on specific time intervals.

Example:
index=main sourcetype=test (event=eventA OR eventB)
| bin _time span=1h
| stats count by _time, event

Sample Result:

_time Event count
04/27 1:00AM EventA 10
04/27 2:00AM EventA 10
04/27 1:00AM EventB 10

How can I show row with zero value? 
_time Event count
04/27 1:00AM EventA 10
04/27 2:00AM EventA 10
04/27 3:00AM EventA 0
04/27 1:00AM EventB 10
04/27 2:00AM EventB 0
04/27 3:00AM EventB 0

 

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The stats command will not fill in missing values, but timechart will.

 

index=main sourcetype=test (event=eventA OR eventB)
| timechart span=1h count by event

 

 

---
If this reply helps you, Karma would be appreciated.

whitefang1726
Path Finder

I was expecting a non-timechart command, but that works. Better than creating long queries. 😄

Thanks!

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If your problem is resolved, then please click the "Accept as Solution" button to help future readers.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...