Splunk Enterprise Security

how to create a threshold alert based on previous data?

ahmar74
Explorer

I started off with the following search which gives me failed authentication to cisco acs on a daily basis, now i want to alert when a spike occurred on either day. For example, Monday received 100 failed logins and the following monday we received 1000 failed logins, i want to alert when that occurs but i am stumped, any suggestions.

| tstats summariesonly count values(Authentication.action) as Action from datamodel="Authentication" where (index=acs Authentication.action="failure") by _time span=1day
| convert timeformat="%A %d %B" ctime(_time)

renjith_nair
Legend

Hi @ahmar74,
Try this

|tstats summariesonly count values(Authentication.action) as Action from datamodel="Authentication" where (index=acs Authentication.action="failure") by _time span=1day
|eval week_day=strftime(_time,"%a")|sort week_day|streamstats current=f last(current) as prev by week_day
|eval diff=abs(current-prev)
|where diff > "your threshold value of spike"
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

renjith_nair
Legend

Hi @ahmar74,
Did this work for you?

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

Ghanayem1974
Path Finder

it looks good but having issues with the where diff, as i don't know a number to input.

0 Karma

Ghanayem1974
Path Finder

actually i keep getting error 'The search job has failed due to an error.'

0 Karma

Ghanayem1974
Path Finder

it did not like summariesonly so i removed it, but i can use some help on the where diff >, any ideas? thanks.

0 Karma

renjith_nair
Legend

Hi @Ghanayem1974, The value of threshold has to be decided by you based on your environment. You could think about a percentage also , for e.g. if the failures are more than 50% then alert e.t.c

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

ghanayem74
New Member

how would I write that?

0 Karma

renjith_nair
Legend

Try this run anywhere example

|tstats count as current where index=_internal by _time
 |eval week_day=strftime(_time,"%a")|sort week_day
 |streamstats current=f last(current) as prev by week_day|fillnull value="NA"
 |eval diff=if(prev=="NA",current,abs(current-prev))
 |eval perc_of_change=round((diff/prev)*100,2)|where perc_of_change > 20
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

Sukisen1981
Champion

If I am getting this correct - you have some data on failed logins on a daily basis, and your alert trigger is based on a day of the week comparison? In the example that you have given,if on the previous Monday you had 100 failed logins and on the following Monday you have 101 failed logins , an alert should be triggered?. Is it possible to attach a snapshot of the output that you are receiving in your statistics tab? May be a mock up?

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 ...