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!

Mile High Learning with Splunk University, Denver, Colorado

If Denver is known for its mile-high elevation, Splunk University is about to raise the bar on technical ...

IT Service Intelligence 5.0 Series: Your Guide to the June Launch

We are excited to announce the June release of Splunk IT Service Intelligence (ITSI) 5.0. This update ...

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...