Alerting

Generate email alerts based on conditions

hushang999
New Member

Hello,

I'm trying to create searches for that would generate emails for the following conditions:

1 ) If the "transaction_date" field is more than three days after the "term_date" then send out an email

2 ) If the "lastlogon" date is more than one day after the "term date" then send out an email

3 ) Send out a monthly report for showing #1 and #2

So far I'm using the following search to generate the search:

"eventtype=sws_employee_terms transaction_type=Terminate"

Tags (2)
0 Karma

lguinn2
Legend

Assuming that the date fields are stored in Linux epoch time

eventtype=sws_employee_terms transaction_type=Terminate
| where (transaction_date > term_date + (3 * 86400)) OR (lastlogon > term_date + 86400)

Set up the alert to trigger for number of results > 0 and set the trigger action to email.

Run the same search over a 30 days period to see the report. You could also start with this search and then format the report better.

If the date fields are NOT stored in Linux epoch time, use this to convert them

| eval transaction_date = strptime(transaction_date,"%Y-%m-%d %H:%M:%S")
| eval term_date = strptime(term_date,"%Y-%m-%d %H:%M:%S")
| eval lastlogon = strptime(lastlogon,"%Y-%m-%d %H:%M:%S")

Insert these lines after the first line of the original search. Edit the format strings as needed.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

For time-related maths you may want to look at relative_time(): http://docs.splunk.com/Documentation/Splunk/6.1.1/SearchReference/CommonEvalFunctions
That'd turn the where row into this:

... | where (transaction_date > relative_time(term_date, "+3d")) OR (lastlogon > relative_time(term_date, "+1d"))
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...