Splunk Search

count(failure) is returning 0 always

Jiten009
Explorer

Hi,

I am trying to find the count of total failure to calculate the failure percentage.

| stats count(eval(eventtype="failure")) AS Failed

OR

| stats count("failure") AS Failed

In both the cases its always returning 0, whereas I have failure status count is 300 in my logs.

Please help me out in resolving this.

Tags (1)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

The first stats is correct, provided you have a field named eventtype that occasionally has the value "failure".

As a different approach, try top eventtype instead of stats count.

View solution in original post

0 Karma

lguinn2
Legend

This will avoid the problem of case-sensitivity:

<yourbasesearch>  eventtype="failure" | stats count

And it is probably more efficient. You should try to eliminate as many events as possible in the initial search.

BTW, search is case-insensitive for values, and that includes field values. But the stats command and the eval function are case-sensitive.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

The first stats is correct, provided you have a field named eventtype that occasionally has the value "failure".

As a different approach, try top eventtype instead of stats count.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Was just about to post that 🙂

0 Karma

Jiten009
Explorer

ya, got it the keyword 'Failure' in search is case sensitive.

0 Karma

Jiten009
Explorer

yes, I have a field in my log with name eventtype which has value failure i.e host=168.94.64.138,eventtype=Failure,facetFieldPrefix="1

Thanks for your reply.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...