Alerting

Generate a alert when the Status field change from three or more faliures to success.

godman
Path Finder

In the events we have Status Field where the values are Success and Failures and I want an alert when the Status field changes from 3 or more consecutive failures to Success.

Tags (2)
0 Karma
1 Solution

niketn
Legend

@godman, slightly different approach than @renjith.nair's answer as it looks for 3 or more failures before success in the final where clause.

| gentimes start=-20 increment=1d
| eval _time=starttime
| fields _time
| appendcols [| makeresults
| eval status="success,failed,failed,failed,success,success,success,failed,failed,success,failed,failed,failed,success,success,failed,failed,failed,failed,success" 
| makemv delim="," status 
| mvexpand status]
| streamstats count by status reset_on_change=true
| reverse
| streamstats last(status) as nextStatus current=f window=1
| where nextStatus="success" and count>=3

PS: Depending on the chronological or reverse chronological sort of actual data the reverse command might need to be changed. The above run anywhere example generates chronological sorted events by default. Commands from |gentimes till | mvexpand status] generate some sample status with time.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@godman, slightly different approach than @renjith.nair's answer as it looks for 3 or more failures before success in the final where clause.

| gentimes start=-20 increment=1d
| eval _time=starttime
| fields _time
| appendcols [| makeresults
| eval status="success,failed,failed,failed,success,success,success,failed,failed,success,failed,failed,failed,success,success,failed,failed,failed,failed,success" 
| makemv delim="," status 
| mvexpand status]
| streamstats count by status reset_on_change=true
| reverse
| streamstats last(status) as nextStatus current=f window=1
| where nextStatus="success" and count>=3

PS: Depending on the chronological or reverse chronological sort of actual data the reverse command might need to be changed. The above run anywhere example generates chronological sorted events by default. Commands from |gentimes till | mvexpand status] generate some sample status with time.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

renjith_nair
Legend

@godman,

Are you looking for something similar to

|makeresults|eval status="success,failed,failed,failed,success,failed,failed,success,failed"|makemv delim="," status|mvexpand status
|streamstats count by status reset_on_change=true|delta count as difference|where difference==-2 AND status=="success"
---
What goes around comes around. If it helps, hit it with Karma 🙂
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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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