Splunk Search

Failed Login Query

Mmilaham
Loves-to-Learn

Hello,

I am trying to write a query that will display failed logins (Account_Name, Host, Count).

First Query

index=wineventlog EventCode=4625 | top limit=20 Account_Name host  | where count > 9

Con

1. Displays "-" in some of the Account_Name fields 

Mmilaham_0-1639775438530.png

Pro

1. Displays all the count and host fields correctly.

Second Query

index=wineventlog EventCode=4625  | rex "(?ms)Account For Which Logon Failed.+?Account Name:\s+(?<Account_Name>\V+)" |top limit=30 Account_Name host| where count >=9

Con

Displays all the Account_Name, count and host fields correctly but displays a lot less results on the table compared to the first query.

 

Pro

Displays all the Account_Name, count and host fields correctly

 

I need a query that will displays all the Account_Name, count and host fields correctly as well as displays the same amount of results in the first query. Any help is appreciated. Thanks in advance. 

 

Labels (3)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Once you start filtering out undesired account names the number of results will change.  Perhaps this is more like what you're looking for.

 

index=wineventlog EventCode=4625 Account_Name!="-" ```Filter out -```
```Count names```
| stats count by Account_Name host
```Filter out accounts with fewer than 10 failures```
| where count > 9
```Sort in descending order by count and take the top 20 results```
| sort 20 - count

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

Mmilaham
Loves-to-Learn

I'm still getting fewer result compared to running the first query. Also some of the Account Name are wrong(It's just displaying the Host name).

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Like I said, it's not possible to discard some results and still end up with the same number of results.

The stats command should not be returning results with just the host name in them.  Please share your output (sanitized as necessary).

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...