Splunk Search

how to find difference between two "stats count" used in two different saved search

snabi
Explorer

So i have two saved search queries
1. sourcetype="x" "attempted" source="y" | stats count
2. sourcetype="x" "Failed" source="y" | stats count

i need to create a search query which will calculate

Passed item = (sourcetype="x" "attempted" source="y" | stats count) - (sourcetype="x" "Failed" source="y" | stats count)

and display Passed item count by hours

Tags (1)
0 Karma
1 Solution

snabi
Explorer

sourcetype="x" source="x.log" ("consolidation succeeded" OR "conversion failed") | stats count(eval(searchmatch("consolidation succeeded"))) as attempts count(eval(searchmatch("xconversion failed"))) as failures | eval successes=attempts-failures

this one worked for me...
Thanks for all the supports

View solution in original post

0 Karma

snabi
Explorer

sourcetype="x" source="x.log" ("consolidation succeeded" OR "conversion failed") | stats count(eval(searchmatch("consolidation succeeded"))) as attempts count(eval(searchmatch("xconversion failed"))) as failures | eval successes=attempts-failures

this one worked for me...
Thanks for all the supports

0 Karma

icenitesh
Engager

("SSO Initiated" OR "SSO Completed") | stats count(eval(searchmatch("SSO Initiated"))) as SSO_Initiated count(eval(searchmatch("SSO Completed"))) as SSO_Completed | eval Difference=SSO_Initiated-SSO_Completed

I want to create alert if Difference > 0, then mail needs to be sent.  This check should keep happening every 15 minute and check in last 15 minute if Difference > 0, then trigger mail.

 

0 Karma

starcher
Influencer

give this a shot:
sourcetype="x" | stats count(eval(searchmatch("attempted"))) AS numattempts count(eval(searchmatch("Failed"))) AS numfails | eval diff=numattempts-numfails

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...