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
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...