Splunk Search

Need help on how to alert if daily count exceed 30 days average

acesolar
Engager

Hi all,

   Need some advice here. I have some logs that has the URL and the HTTP  response code.

   Sample here 

POST /abc/xyz 200
POST /abc/xyz 401
POST /abc/xyz 500

  Is there a way for me to do a search so that I can compare today count by response code, and alert if the count exceeds the 30 days average count of the response code?

 

Thanks

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Do a count by day for the last 30 days, then use eventstats to add a column with the average to every event, then reduce your events to just cover the day (or days) you are interested in, and compare the daily count to the average. Something like this

| bin span=1d _time
| stats count by _time response_code
| eventstats avg(count) as average by response_code
| where _time >= relative_time(now,"@d")
| where count>average

 

View solution in original post

0 Karma

acesolar
Engager

Thank you. It worked like a charm

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Do a count by day for the last 30 days, then use eventstats to add a column with the average to every event, then reduce your events to just cover the day (or days) you are interested in, and compare the daily count to the average. Something like this

| bin span=1d _time
| stats count by _time response_code
| eventstats avg(count) as average by response_code
| where _time >= relative_time(now,"@d")
| where count>average

 

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