Splunk Search

Conditional Sum

rackersmt
Explorer

I'm trying to create a report of domain accounts locked out by caller_computer_name. However, I want to alert if the total lockout count exceeds a threshold for a given account. The problem is that one computer can lockout an account 5 times, and another 16 times, and that exceeds the threshold, but not individually. The threshold is by account, not by account and computer, but I also want to see the caller computer. Any ideas? The last command in the string below doesn't actually work, but it gives you an idea of what I'm trying to do.

EventCode=4740 earliest=-24h | rex field=_raw "(?s)(?i)Account\sThat\sWas\sLocked\sOut.+?Account\sName:\s+(?\S*)" | stats count by account_name,Caller_Computer_Name | where sum(count) by SSO > 20

Thanks!

Tags (3)
0 Karma
1 Solution

javiergn
Super Champion

Try the following (not tested):

EventCode=4740 earliest=-24h 
| rex field=_raw "(?s)(?i)Account\sThat\sWas\sLocked\sOut.+?Account\sName:\s+(?\S*)" 
| stats count by account_name,Caller_Computer_Name 
| eventstats sum(count) as account_count by account_name
| where account_count > 20

View solution in original post

somesoni2
Revered Legend

When you say individual lockout count for a caller_computer_name should exceed your threshold, you already have count of generated in that way only. You can just add a "where count > 20" and that should do it.

0 Karma

rackersmt
Explorer

I need the threshold by account, not account and computer. Say the threshold is 20. If computer A locked out an account 17 times, I wouldn't want to alert on that. But if computer B also locked out the account 5 times, I would want to alert. javiergn actually posted an answer that's exactly what I was looking for.

0 Karma

javiergn
Super Champion

Try the following (not tested):

EventCode=4740 earliest=-24h 
| rex field=_raw "(?s)(?i)Account\sThat\sWas\sLocked\sOut.+?Account\sName:\s+(?\S*)" 
| stats count by account_name,Caller_Computer_Name 
| eventstats sum(count) as account_count by account_name
| where account_count > 20

rackersmt
Explorer

This is perfect, thanks!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...