Splunk Search

How to write a search to create a summary index with a count of "0" when there are no events matching "myerror"?

burwell
SplunkTrust
SplunkTrust

I have a search to create a summary index which runs every 15 minutes:

 index=foo "myerror" | bin span=15m _time |  sistats count by _time

I'd like to have 0 in my summary search when there are no events matching "myerror".

How do I do that?

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Give this a try

  index=foo "myerror" | bin span=15m _time |  sistats count by _time | appendpipe [| stats count | where count=0 | addinfo  | eval _time=info_min_time| bucket span=15m _time | table _time count | sistats count by _time ]

burwell
SplunkTrust
SplunkTrust

I tried this (I am getting rid of the bin span)... this works except when there are no errors then it says 1 instead of 0.

I tried adding eval count=count-1 in the appendpipe clause but could not get this to give me zero.

index=foo "myerror" | sistats count |appendpipe [| stats count | where count=0 | addinfo  | eval _time=info_min_time|  table _time count |  sistats count    ]
0 Karma

jkat54
SplunkTrust
SplunkTrust

See if this works: Change it from sistats to stats and use the collect command..,

 ... | stats count by _time | collect index=summary 
0 Karma

burwell
SplunkTrust
SplunkTrust

Thanks but that didn't do it. I don't get data when I have no events.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...