Splunk Search

How to disable splunk alert for a specific time frame?

rzv424
Engager

We want an alert to run every day (Monday-Sunday) on a 30 minutes interval with one exception. The exception is it should not run specifically on Wednesday and Friday from 5AM to 8AM. However it should run on other hours on Wednesday and Friday as well  (apart from 5AM to 8AM)

One cron is not able to achieve that. Hence want to change in the alert logic.

0 Karma
1 Solution

subham29
Engager

@rzv424 
Solution1:

You can create two alerts with the same logic with different CRONs.

  1. 1st alert CRON will run every day except on Wed and Fri. Cron is: */30 * * * 0,1,2,4,6
  2. Second alert CRON will run every 30 minutes on Wednesday and Friday and will stop from 5AM to 8AM. Cron is: */30 0-5,8-23 * * 3,5

Solution2:

You can create one alert with a CRON to run every day of the week at 30 minutes interval, Cron is */30 * * * *

And you can add the filtering at the logic of query itself:
Use an EVAL command to output the current day and hour after your logic ends. and then filter or don't show your outputs as per your exception requirement

......| eval now_day=strftime(now(), "%a"), now_hour=strftime(now(), "%H")
| search NOT ((now_day="Wed" AND (now_hour="5" OR now_hour="6" OR now_hour="7" OR now_hour="8")) OR (now_day="Fri" AND (now_hour="5" OR now_hour="6" OR now_hour="7" OR now_hour="8")))

View solution in original post

0 Karma

subham29
Engager

@rzv424 
Solution1:

You can create two alerts with the same logic with different CRONs.

  1. 1st alert CRON will run every day except on Wed and Fri. Cron is: */30 * * * 0,1,2,4,6
  2. Second alert CRON will run every 30 minutes on Wednesday and Friday and will stop from 5AM to 8AM. Cron is: */30 0-5,8-23 * * 3,5

Solution2:

You can create one alert with a CRON to run every day of the week at 30 minutes interval, Cron is */30 * * * *

And you can add the filtering at the logic of query itself:
Use an EVAL command to output the current day and hour after your logic ends. and then filter or don't show your outputs as per your exception requirement

......| eval now_day=strftime(now(), "%a"), now_hour=strftime(now(), "%H")
| search NOT ((now_day="Wed" AND (now_hour="5" OR now_hour="6" OR now_hour="7" OR now_hour="8")) OR (now_day="Fri" AND (now_hour="5" OR now_hour="6" OR now_hour="7" OR now_hour="8")))

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You have two options:

  1. Duplicate the alert and use a different cron expression for the different days/time periods
  2. Use now() function to determine when the search is running and modify the results so that the alert isn't triggered.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...