Alerting

Alert scheduling - cron expression not working as expected

mattbg
Path Finder

I'm trying to schedule a particular alert to run on the first Monday of each fiscal quarter using this cron expression:

 

0 9 1-7 2,5,8,11 1

 

My reading of this is "9:00am on the first Monday of Feb, May, Aug, and Nov".

However, with this month being November (11) for some reason it is running it every Monday. It unexpectedly ran this past Mon Nov 16th and has a "next scheduled time" of Mon Nov 23rd. Given the day-of-month restriction (3rd field) of 1-7 I would not have expected this to happen.

Any advice appreciated. Splunk Enterprise 8.0.6. Thanks.

Labels (2)
0 Karma
1 Solution

teunlaan
Contributor

It's not a bug, crontab.guru gives the correct explenation.

"At 09:00 on every day-of-month from 1 through 7 and on Monday in February, May, August, and November.”

the 16th was a Monday

 

 

View solution in original post

mattbg
Path Finder

I ended up using this cron expression to run on monthdays 1-7 regardless of the weekday:

 

0 9 1-7 2,5,8,11 *

 

...and then filtering my results so that I only got results on Mondays:

 

…
| eval today_weekday=strftime(now(), “%w”)
| where today_weekday=1

 

I couldn't use a time range filter because the underlying data can be generated at any time and the alert just sends the most recent results that exist at the start of the quarter.

teunlaan
Contributor

It's not a bug, crontab.guru gives the correct explenation.

"At 09:00 on every day-of-month from 1 through 7 and on Monday in February, May, August, and November.”

the 16th was a Monday

 

 

richgalloway
SplunkTrust
SplunkTrust

According to crontab.guru, that cron expression means "At 09:00 on every day-of-month from 1 through 7 and on Monday in February, May, August, and November.” (https://crontab.guru/#0_9_1-7_2,5,8,11_1)

That the alert ran on the 16th seems like a bug to me.  I suggest opening a support request with Splunk.

---
If this reply helps you, Karma would be appreciated.
0 Karma
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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...