Splunk Search

Is it possible to use streamstats over a 3 minute window over a 9 minute search to pick up three consecutive events?

becksyboy
Contributor

Hi I have an ask to create an alert that must trigger if there are more than 50 '404' status codes in a 3 min period. This window must repeat three times in a row - for e.g 9:00 - 9:03, 9:03 - 9:06, 9:06 - 9:09.   The count should trigger only for those requests with 404 status code and for certain urls. The alert must only trigger if there are three values over 50 in consecutive 3 min windows.

I have some initial SPL not using streamstats, but was wondering if streamstats would be better?

Initial SPL - run over a 9 min time range:

index="xxxx" "httpMessage.status"=404 url = "xxxx/1" OR url="xxxx/2" OR url ="xxxx/3"
| timechart span=3m count(httpMessage.status) AS HTTPStatusCount
| where HTTPStatusCount>50
| table _time HTTPStatusCount

 

thanks.

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

What you are doing will work fine assuming your alert is triggering is there are 3 results i.e. all of the 3 minute slots in your 9 minute period have counts greater than 50.

Using streamstats would give you something different and doesn't quite fit with your stated requirement.

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

What you are doing will work fine assuming your alert is triggering is there are 3 results i.e. all of the 3 minute slots in your 9 minute period have counts greater than 50.

Using streamstats would give you something different and doesn't quite fit with your stated requirement.

becksyboy
Contributor

Thanks for the additional validation on my initial search.

0 Karma

isoutamo
SplunkTrust
SplunkTrust
It exactly this way. The key word here is fixed window or sliding window. With fixed window time chart is correct way to do it, but if you need to look those event in sliding window (it change start and end time continuously based on current event) then you must use stream stats.
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

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