Alerting

Stop splunk alerts when the alert results are same as previous result within 30 min window

ashrafsj
Path Finder

Hi,

 

I'm trying to reduce the number of alerts in Splunk, at the moment we receive splunk alert on queue size every 30 min. The problem here is the queue size/depth is the same when it triggers every 30 min, I need a solution so that we could check the previous queue size and the current queue size and stop alerting if they are same.

index=day sourcetype="mqmon" EventType="QueueDepth" QDepth>0 
| eval time=strftime(_time,"%d %b %Y %H:%M %p")
| stats latest(QDepth) As QueueSize,max(time) As LastEvent by host, QMan, QName


Labels (2)
0 Karma
1 Solution

FrankVl
Ultra Champion

@ashrafsj apologies, I indeed forgot to add a by-clause to the eventstats. This should work better:

index=day sourcetype="mqmon" EventType="QueueDepth" QDepth>0 
| eval time = _time
| bin time span=30min
| stats latest(QDepth) As QueueSize,max(_time) As LastEvent by time,host, QMan, QName
| eval _time=time
| eventstats earliest(QueueSize) as PrevQueueSize by host, QMan, QName
| where QueueSize!=PrevQueueSize
| eval LastEvent=strftime(LastEvent,"%d %b %Y %H:%M %p")

View solution in original post

FrankVl
Ultra Champion

Something like this should work. Run it every 30min over last 60min (instead of your current 30min):

index=day sourcetype="mqmon" EventType="QueueDepth" QDepth>0 
| eval time = _time
| bin time span=30min
| stats latest(QDepth) As QueueSize,max(_time) As LastEvent by time,host, QMan, QName
| eval _time=time
| eventstats earliest(QueueSize) as PrevQueueSize
| where QueueSize!=PrevQueueSize
| eval LastEvent=strftime(LastEvent,"%d %b %Y %H:%M %p")

Note: I've also moved the timestamp to string conversion to the end, otherwise max() will have incorrect results (the timestamp format you use does not sort chronologically).

0 Karma

ashrafsj
Path Finder

Thanks @FrankVl , I tried your query. The original query had returned  52 results and this one has returned 152 results and all the PrevQueueSize values shows 4 for all the queues.  It doesn't seem to pick the previous queue size of each queue. 

0 Karma

FrankVl
Ultra Champion

@ashrafsj apologies, I indeed forgot to add a by-clause to the eventstats. This should work better:

index=day sourcetype="mqmon" EventType="QueueDepth" QDepth>0 
| eval time = _time
| bin time span=30min
| stats latest(QDepth) As QueueSize,max(_time) As LastEvent by time,host, QMan, QName
| eval _time=time
| eventstats earliest(QueueSize) as PrevQueueSize by host, QMan, QName
| where QueueSize!=PrevQueueSize
| eval LastEvent=strftime(LastEvent,"%d %b %Y %H:%M %p")

ashrafsj
Path Finder

Thanks a lot @FrankVl , that worked for me. Many thanks!

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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...