Splunk Search

Creating an alert with field value count within a transaction

mcg_connor
Path Finder

I am trying to create an alert for the below search that would go off if within the event there are 10 times where EventCode equals 1 within a 5-minute span. I also want EventCode equals 2 once within that span which is why I am doing the search for EventID equals 1 AND EventID equals 2.

index="myindex" EventCode=1 OR EventCode=2   earliest=-5m
| transaction user   | search EventID=1 AND EventID=2  
| eventstats 
                count(eval(match(EventID,"1"))) as loginFail
                count(eval(match(EventID,"2"))) as loginSuccess
                by user
|table user,loginFail,loginSuccess
|where loginFail >= 10

Currently the results of this search are:

user                          loginFail            loginSuccess
testuser                          1                      1
exampleuser                       1                      1

Even if there are 3 times within the transaction where EventID equals 1 and 1 time where it equals 2.

Thanks for any help!

0 Karma
1 Solution

woodcock
Esteemed Legend

DO NOT user transaction; try this:

index="myindex" AND (EventCode=1 OR EventCode=2) earliest=-5m
| eventstats count(eval(EventCode=1)) AS loginFail count(eval(EventCode=2)) AS loginSuccess BY user
| where loginFail >= 10 AND loginSuccess > 0

View solution in original post

woodcock
Esteemed Legend

DO NOT user transaction; try this:

index="myindex" AND (EventCode=1 OR EventCode=2) earliest=-5m
| eventstats count(eval(EventCode=1)) AS loginFail count(eval(EventCode=2)) AS loginSuccess BY user
| where loginFail >= 10 AND loginSuccess > 0

mcg_connor
Path Finder

Awesome thanks for the helpful answer!

0 Karma
Get Updates on the Splunk Community!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...