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!

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