Alerting

Email Alert With Sub-Searches, Comparing Sub-Search Results

torndorff
Explorer

I’m attempting to write an alert that fetches full event data while also comparing the counts of 2 other searches. The idea being that if C1 is greater than or equal to C2, an alert is fired with an email alert action, attaching the events so that business users can receive check it from their phone.

This is the best I could come up with but it doesnt work. Anyone out there able to lend a hand?

index=main loglevel=ERROR | stats
count by _raw | appendcols
[ search index=main loglevel=WARN
| stats count(convId) AS C1 ] | appendcols
[ search index=main loglevel=ERROR
| stats count(convId) AS C2]
| where C1 >= C2

Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

Just add | filldown C1 C2 before the where clause; this worked for me:

index=_* | stats count BY sourcetype 
| appendcols 
    [| makeresults 
    | eval C1=30 | table C1] 
| appendcols 
    [| makeresults 
    | eval C2=20 | table C2]
| filldown C1 C2
| where C1>=C2

View solution in original post

woodcock
Esteemed Legend

Just add | filldown C1 C2 before the where clause; this worked for me:

index=_* | stats count BY sourcetype 
| appendcols 
    [| makeresults 
    | eval C1=30 | table C1] 
| appendcols 
    [| makeresults 
    | eval C2=20 | table C2]
| filldown C1 C2
| where C1>=C2

torndorff
Explorer

Thanks! filldown is a new one for me.

0 Karma
Get Updates on the Splunk Community!

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

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...