Splunk Search

Need Solution for stats command

rakesh_498115
Motivator

Hi i have my query something like this .

sourcetype="X" (some logic) |transaction keepevicted=true uniqueID |where duration>0 | stats count as Total | eval cond=(duration/60) | where cond < 30 | stats count as Passed | table Passed,Total

But i am not getting the results..

In the Total field i need the count of events that are below duration < 0

In the Passed field i need the count of events that are below duration < 0 and cond < 30

How can i get this ?? Please help...

Tags (2)
0 Karma
1 Solution

ziegfried
Influencer

By doing stats count as Total you're removing all fields from the results stream, so there will be no duration fields you could use in the subpipeline. Probably more reasonable search:

sourcetype="X"  (some logic) | transaction keepevicted=true uniqueID | where duration>0 | eval passed=if(duration/60 < 30, "Yes","No") | stats count(eval(passed="Yes")) as Passed count as Total

or simpler

sourcetype="X"  (some logic) | transaction keepevicted=true uniqueID | where duration>0 | stats count(eval(duration/60 < 30)) as Passed count as Total

View solution in original post

ziegfried
Influencer

By doing stats count as Total you're removing all fields from the results stream, so there will be no duration fields you could use in the subpipeline. Probably more reasonable search:

sourcetype="X"  (some logic) | transaction keepevicted=true uniqueID | where duration>0 | eval passed=if(duration/60 < 30, "Yes","No") | stats count(eval(passed="Yes")) as Passed count as Total

or simpler

sourcetype="X"  (some logic) | transaction keepevicted=true uniqueID | where duration>0 | stats count(eval(duration/60 < 30)) as Passed count as Total
Get Updates on the Splunk Community!

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 ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...