Splunk Search

Creating a SPL using tstats for Multiple Failed Logins Followed by Success?

randqm
Loves-to-Learn Everything

Hello Splunk Community,

I'm currently working on creating a search using the tstats command to identify user behavior related to multiple failed login attempts followed by a successful login. I want to use tstats for this due to its efficiency with high volumes of data, compared to the transaction command.

In my case, I want to be able to detect an event sequence where a user has had, let's say, 10 or more failed login attempts, followed by a successful login attempt, within a specified time window (for example, within an hour).

I understand that tstats doesn't provide the same level of detail as transaction for creating sequences of events. However, I'm looking for suggestions on how to use tstats, combined with other SPL commands, to achieve a similar result.

Here's an example of the type of data I'm dealing with:

_time user status

1622890560 user1 failure
1622890620 user1 failure
1622890680 user1 success

In this example, the status field contains "success" or "failure", and the user field contains the user ID.

Any guidance or suggestions would be greatly appreciated.

Thanks in advance for your help!

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @randqm ,

you can use tstats only on a DataModel or on index time fields, so probably user field isn't indexed.

If you haven't a DM, you should use the stats command that much faster than transaction, if you're speaking of windows logs, you could try something like this:

index=wineventlog (EventCode=4624 OR EventCode=4625)
| stats 
   count(eval(EventCode=4624)) AS success_count 
   count(eval(EventCode=4625)) AS failed_count
   by host user
| where success_count>0 AND failed_count>10

if you have different data sources, adapt the search using the success and failed conditions of your data sources.

Ciao.

Giuseppe

0 Karma

sabkha
Loves-to-Learn

but this won't show sequence, how can we have a search that shows successful login after failed logins ( in sequence)

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Your Feedback. Our Roadmap. Visit the PX Feedback Booth at .conf26

You use Splunk every day, come and help shape what's next.  Save Your Seat: Product-Focused Sessions at ...

Agentic SOC Triage: Investigating Splunk ES Notables with MCP Server and a Local LLM

The Problem: Too Many Alerts, Too Little Context Security operations teams running Splunk Enterprise Security ...

Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas

Watch Now Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas     Do you ever feel ...