Other Usage

How to define 2 thresholds based on time?

cbiraris
Path Finder

Hi Team,

I am trying to schedule a alert base on threshold for 2 time window.

If fall to 0 events between 23:00 to 07:00
If fall to less then 20 events between   07:00 to 23:00 
 
is it possible to define 2 threshold like above ? in one alert

index=ABC sourcetype=XYZ login |stats count |where count =0 between23:00 to 07:00

index=ABC sourcetype=XYZ login |stats count |where count <=20 between 07:00 to 23:00 

Please advise.

Thank you

Labels (1)
Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @cbiraris,

yes, you have to define a threshold value using eval:

index=ABC sourcetype=XYZ login 
| stats count 
| eval time_hour=strftime(now(),"%H")
| eval threshold=if(time_hour>22 OR time_hour<8,0,20)
| where count<=threshold

Ciao.

Giuseppe

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
index=ABC sourcetype=XYZ login |stats count |where count=0 OR (count <=20 AND tonumber(strftime(now(),"%H")) >= 7 AND tonumber(strftime(now(),"%H")) < 23)

gcusello
SplunkTrust
SplunkTrust

Hi @cbiraris,

yes, you have to define a threshold value using eval:

index=ABC sourcetype=XYZ login 
| stats count 
| eval time_hour=strftime(now(),"%H")
| eval threshold=if(time_hour>22 OR time_hour<8,0,20)
| where count<=threshold

Ciao.

Giuseppe

cbiraris
Path Finder

Also, can we define 2 different search run interval in this query ? like below---

index=ABC sourcetype=XYZ login |stats count |where count =0 between23:00 to 07:00, search can be run every after 2 hours to check last 2 hours events 

AND 


index=ABC sourcetype=XYZ login |stats count |where count <=20 between 07:00 to 23:00, , search can be run every after 1 hours to check last 1 hours events 
 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You can do this in one alert but it gets a bit messy - you would probably be better off using two alerts with different schedules, time periods and alert criteria

0 Karma

cbiraris
Path Finder

Thank you @gcusello
Its Working

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...