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!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...