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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

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