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!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...