Alerting

Splunk Alert

sarahnazzar
Explorer

Hello Splunkers,

I'm having an alert with last 3 days as the time range and that alert is triggered everyday at a particular time showing the last 3 days data.. Now the thing I need is, the alert should be triggered when it is having data for the current day and it should not trigger if it is having data for the previous days.. in addition to this condition, when the alert is having data for the current day then I must get the previous days data too no matter what..

Note: My search time range must be last 3 days.. is that possible?

Thanks in advance!

Tags (1)
0 Karma
1 Solution

renjith_nair
Legend

@sarahnazzar ,

Try this and see if it fits your requirement.

"your current search"
|eval date=strftime(_time,"%Y-%m-%d")
|eventstats dc(date) as noOfDays,max(_time) as latest_date
|eval latest_date=strftime(latest_date,"%Y-%m-%d")|eval current_date=strftime(now(),"%Y-%m-%d")
|where latest_date==current_date AND noOfDays>=3

This would give you results if latest date in the result is current date and if you have atleast 3 days of data in your results.

---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

0 Karma

renjith_nair
Legend

@sarahnazzar ,

Try this and see if it fits your requirement.

"your current search"
|eval date=strftime(_time,"%Y-%m-%d")
|eventstats dc(date) as noOfDays,max(_time) as latest_date
|eval latest_date=strftime(latest_date,"%Y-%m-%d")|eval current_date=strftime(now(),"%Y-%m-%d")
|where latest_date==current_date AND noOfDays>=3

This would give you results if latest date in the result is current date and if you have atleast 3 days of data in your results.

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

sarahnazzar
Explorer

Thanks for the help! It's working fine..

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!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2026-2027 SplunkTrust is officially open. If ...