Splunk Enterprise Security

Splunk Enterprise Security: How to set a custom risk score based on stats results?

stevenjluke
Explorer

I would like to set a custom risk score based on the number of failed authentication attempts by a user. I created the search:

index=msadauth EventID=4771 OR EventID=4768 OR EventID=4776 action=failure | eval app="Active Directory" | stats count by user,src,app | lookup dnslookup clientip as src OUTPUT clienthost as src_resolved | eval src=if(isnull(src_resolved),src,src_resolved) |rename count as failed_auth_count| fields user,src,app,failed_auth_count |eval risk_score=failed_auth_count
| sendalert risk  param._risk_object=user param._risk_object_type="user" 

What is happening a single user account returns 2 results from stats. However, the sendalert for the risk creates multiple entries for each stats result in the risk index. I'm guessing that the send alert is running as the stats results reduce.

Is there a way to have stats finish reducing before it continues to the next search command?

0 Karma

LAntoniak
Explorer

I tend to use appendpipe to avoid race conditions, to my understanding it pauses the search while it processes everything up to that point before opening up the appendpipe.

| appendpipe [ | makeresults | fields - _time ]

https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Appendpipe

"Appends the result of the subpipeline to the search results. Unlike a subsearch, the subpipeline is not run first. The subpipeline is run when the search reaches the appendpipe command. "

0 Karma

stevenjluke
Explorer

I figured out a way that works but am wondering if there is a better way. I made the search a subsearch and appended the results to nothing. By doing it this way the risk events and the number out of the stats match.

 | append [search index=msadauth EventID=4771 OR EventID=4768 OR EventID=4776 action=failure | eval app="Active Directory" | stats count by user,src,app | lookup dnslookup clientip as src OUTPUT clienthost as src_resolved | eval src=if(isnull(src_resolved),src,src_resolved) |rename count as failed_auth_count| fields user,src,app,failed_auth_count |eval risk_score=failed_auth_count  ] | sendalert risk  param._risk_object=user param._risk_object_type="user" 

Does anyone know of a better way to do this?

0 Karma
Get Updates on the Splunk Community!

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Announcing the General Availability of Splunk Enterprise Security 8.1!

We are pleased to announce the general availability of Splunk Enterprise Security 8.1. Splunk becomes the only ...

Developer Spotlight with William Searle

The Splunk Guy: A Developer’s Path from Web to Cloud William is a Splunk Professional Services Consultant with ...
OSZAR »