Alerting

How to send alert for consecutive field values failure

manish_singh_77
Builder

Hi All,

I have a table where we have job_result field, whenever job_result field has "failure" value for consecutive 5 times then we need to set up an alert.

Example

job job _name time job result
abc abc_job 14:20 Failure
def def_job 15:30 Failure
ghi ghi_job 12:22 Failure
annc annc_job 14:20 Failure
defff defff_job 15:30 Failure
ghhhi ghhhi_job 12:22 Failure

Tags (2)
0 Karma

to4kawa
Ultra Champion
| makeresults 
| eval _raw="job   job_name  time job_result
abc   abc_job   14:20 Failure
def   def_job   15:30 Failure
ghi   ghi_job   12:22 Failure
annc  annc_job  14:20 Failure
defff defff_job 15:30 Failure
ghhhi ghhhi_job 12:22 Failure
abc   abc_job   14:20 Success
def   def_job   15:30 Failure
ghi   ghi_job   12:22 Failure
annc  annc_job  14:20 Failure
defff defff_job 15:30 Failure
ghhhi ghhhi_job 12:22 Failure"
| multikv forceheader=1 
| table job job_name time job_result
| streamstats reset_on_change=t count(eval(job_result="Failure")) as fail_count by job_result
| eventstats max(fail_count) as alert_count

Hi, @manish_singh_777
this is sample code.

your_search
| table job job_name time job_result
| streamstats reset_on_change=t count(eval(job_result="Failure")) as fail_count by job_result
| eventstats max(fail_count) as alert_count

alert_count > 5, fire alert.

manish_singh_77
Builder

Hi @to4kawa

I want to send an alert if specific job is failing for 5 consecutive times.

0 Karma

to4kawa
Ultra Champion
your_search
 | table job job_name time job_result
 | streamstats reset_on_change=t count(eval(job="abc" AND job_result="Failure")) as fail_count by job_result
 | eventstats max(fail_count) as alert_count

please add job.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...