Alerting

Splunk Alert needed for a specific time frame

johann2017
Explorer

Hello all, using Splunk Enterprise here. I want to create a Splunk Alert based off one of my searches/saved reports. I need it to run Mon-Sunday between 5pm - 7am the following day in 15 minute intervals. I want it to alert ONLY for events that occur between 5pm - 7am. I almost got it to work, however when the e-mail alert comes in it has a listing of ALL events that happened for the entire day, and I need it to give me events that only occurred in the 5pm-7am range. Here is the Cron Expression I am using: */15 0-7,16-23 * * * Any ideas?

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Cron tells Splunk when to run the search, but it doesn't tell it what data to look at. That's where the Earliest and Latest settings come into play.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

nickhills
Ultra Champion

What about using:
<your search> (date_hour>=17 OR date_hour<7)

and then your cron just runs every 15 mins during your alert hours?

not tested, but feels like it should work 🙂

If my comment helps, please give it a thumbs up!

rodrigo_santos
Explorer

(date_hour>=17 AND date_hour<7)

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Cron tells Splunk when to run the search, but it doesn't tell it what data to look at. That's where the Earliest and Latest settings come into play.

---
If this reply helps you, Karma would be appreciated.
0 Karma

johann2017
Explorer

Hello Rich. Yea I am not really sure how the Earliest and Latest works, I see those options there but does not really make sense in my scenario.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please accept an answer.

---
If this reply helps you, Karma would be appreciated.
0 Karma

somesoni2
Revered Legend

If you open your alert search from "Alerts" dashboard, what is the timerange picker values? OR if you open it from settings, what is the Start time and Finish time values?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Have you clicked the "Learn more" link under those options to see how they work?
The difficulty in your scenario is midnight. Setting Earliest=@d+17h will look for events after 5pm today (Mon), but when the search runs at 00:15 it will look for events after 5pm on Tuesday.
It's a tricky problem for which I don't have a solution at the moment.

---
If this reply helps you, Karma would be appreciated.
0 Karma

johann2017
Explorer

And when I use earliest/latest options do I use the Cron job along with it too or only one or the other?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

You should use both,

---
If this reply helps you, Karma would be appreciated.
0 Karma

johann2017
Explorer

Thanks rich. I used both and I seem to have got it working.

0 Karma

johann2017
Explorer

Could I create two different alerts to solve this? One for 5pm through Midnight and a second alert for Midnight through 7am?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

That's an option.

---
If this reply helps you, Karma would be appreciated.
0 Karma

JDukeSplunk
Builder

Well, if the search runs every 15 minutes, then somewhere in the first search line put

<yourbasesearch> earliest=-15m latest=now  
0 Karma

johann2017
Explorer

Thanks JDuke!

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...