Splunk Search

Sequential event mining

fayedong
Engager

Hi everybody,

I am new to Splunk. I have a question about Splunk query.

Here are some sample logs (timestamp ordered) which record users' success attempts and failure attempts:

TimeStamp UserName Status
t7 UserA success
t6 UserA failure
t5 UserB success
t4 UserC failure
t3 UserC success
t2 UserD failure
t1 UserE success

My question is what should the query like if I want to find out users whose first attempt failed and then second attempt succeeded? .

Thanks.

Tags (1)
0 Karma

fayedong
Engager

stats first(Status) as Status1 last(Status) as Status2 by UserName | search Status1="Success" AND Status2="Failure"

0 Karma

fayedong
Engager

@Martin_mueller, thanks. Streamstats is cool. I don't know this command before but I managed to generate unique event using DEDUP. My actual question is actually what command should I use after having unique event:

How to list those where the first is a failure and the second is a success
and the number of unique users having this sequence?

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

For analysing relationships between events you often need streamstats. For example, appending this

streamstats count by UserName

will give you a unique numbering of events per user. After that you could filter for those where the first is a failure and the second is a success.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

After counting them, you could filter like this:

where (Status="failure" AND count=1) OR (Status="success" AND count=2) | eventstats count by UserName | where count=2

That'll first filter for only those events where the first attempt is a failure and the second attempt is a success, then counts by username and only keeps those that have both attempts - ie filters out two failures or two successes.

I'm not sure whether that's what you need though - what goal are you trying to achieve?

fayedong
Engager

Thanks, martin_mueller. My question actually is : how to filter for those where the first is a failure and the second is a success? 🙂

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!

What’s New in Splunk AI: Volume 02

Welcome to the second edition of “What’s New in Splunk AI” where we look at the latest and greatest updates, ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...

Laser Bananas and Edge Hubs: Exploring Operational Technology (OT) Data Through a ...

  OT is a different environment to traditional IT and can have interesting challenges when interfacing the ...