Other Usage

Setting Rolling seven day average alert with current day data

Akdeveloper
Observer

Hi,

I am trying to setup an alert and notify by email, when count of last 3hrs is greater than rolling average of last 7 days using the below query. Query is working fine but in the alert is not working/not getting triggered I tried as below Alert Config

Trigger conditions in alert Screen are, Trigger alert when ,Custom option ,search alert==true

 

Query:

sourcetype="cloudwatch" index=***** earliest=-6d@d latest=@d
|bucket _time span=1d
|stats count by _time
|stats avg(count) as SevenDayAverage
|appendcols [search sourcetype="cloudwatch" index=*****
|stats count as IndividualCount]
|eval alert = if((IndividualCount.SevenDayAverage),"true","false")
SevenDayAverage IndividualCount alert
5 1139 true

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It is not clear what your if condition is supposed to be doing (was there a typo?), nor indeed what your search is trying to find as you seem to be trying to compare an average daily count with a 3 hour count?

Also, this is potentially going to be very slow - have you considered using metasearch or summary indexes?

0 Karma

Akdeveloper
Observer

Sorry there was typo,this is correct if currently,if((IndividualCount>SevenDayAverage),"true","false").

Reg the query I am trying to compare counts in last three hours with seven day average count,if true then alert.

I didn't tried metasearches,will give a try too

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So you are trying to alert if a 3 hour count is greater than the average for a whole day over the last 6 days?

0 Karma

Akdeveloper
Observer

That's correct @ITWhisperer 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Which version of Splunk are you running as there have been problems with custom alert conditions?

A way to work around this is to add a where command to your search and then alert if there are any results e.g.:

| where alert="true"
0 Karma
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...