Splunk Search

To add multiple criteria to determine drop in traffic

arunsubram
Explorer

index=circuit basequery1 earliest=-10m@m latest=@m|fields count | stats count AS currentMinuteCount | appendcols [search index=circuit basequery1 earliest=-20m@m latest=-10m@m |fields count| stats count AS previousMinuteCount]|where currentMinuteCount < 0.5*previousMinuteCount

This is just a basic check to determine if traffic has dropped below 50% when compared to previous 10 mins traffic count. If this Alert is missed out, then subsequent checks will pass as there would be no traffic. If I don't find any traffic in previous 10 mins, I wanted to check for a window of 30 mins. Any help or suggestion is appreciated.

Tags (1)
0 Karma
1 Solution

lguinn2
Legend

Try this. I dropped the appendcols, as it will slow the search and it makes it harder to do the "fallback" that you want. This may not be exactly what you wanted, but I did this: I retrieved the the past 30 minutes of data and then broke it into 3 categories: the most recent 10 minutes (current), from 10-20 minutes ago (previous) and from 20-30 minutes ago (earliest). After counting the events in each category, I then checked to see if there were any events in the "previous" category. If there were none, I used the "earliest" category for the final comparison.

index=circuit basequery1 earliest=-30m@m latest=@m 
| eval timeSlot=case(_time < relative_time(now(),"-20m"),"Earliest",
          _time < relative_time(now(),"-10m"),"Previous",
          true(),"Current")
| stats count(eval(timeSlot=="Previous")) as previousMinuteCount,  
            count(eval(timeSlot=="Current")) as currentMinuteCount,
            count(eval(timeSlot=="Earliest")) as earliestMinuteCount
| eval compareWith = if(previousMinuteCount>0,previousMinuteCount,earliestMinuteCount)
| where currentMinuteCount < 0.5*compareWith

HTH

View solution in original post

0 Karma

lguinn2
Legend

Try this. I dropped the appendcols, as it will slow the search and it makes it harder to do the "fallback" that you want. This may not be exactly what you wanted, but I did this: I retrieved the the past 30 minutes of data and then broke it into 3 categories: the most recent 10 minutes (current), from 10-20 minutes ago (previous) and from 20-30 minutes ago (earliest). After counting the events in each category, I then checked to see if there were any events in the "previous" category. If there were none, I used the "earliest" category for the final comparison.

index=circuit basequery1 earliest=-30m@m latest=@m 
| eval timeSlot=case(_time < relative_time(now(),"-20m"),"Earliest",
          _time < relative_time(now(),"-10m"),"Previous",
          true(),"Current")
| stats count(eval(timeSlot=="Previous")) as previousMinuteCount,  
            count(eval(timeSlot=="Current")) as currentMinuteCount,
            count(eval(timeSlot=="Earliest")) as earliestMinuteCount
| eval compareWith = if(previousMinuteCount>0,previousMinuteCount,earliestMinuteCount)
| where currentMinuteCount < 0.5*compareWith

HTH

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...