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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...