Splunk Search

How to get info from user's first session?

ysdeos
New Member

I have user logs that look like this per session:

userId=u1 sessionId=s1 level=l1

userId=u1 sessionId=s1 level=l2

userId=u1 sessionId=s2 level=l3

userId=u2 sessionId=s1 level=l2

userId=u2 sessionId=s1 level=l4
...

I want a query that returns the user's last recorded session from the first session he had. Meaning:

userId,sessionId,level

u1,s1,l2

u2,s1,l4

How can I do this?
Thanks!

Tags (1)
0 Karma

Damien_Dallimor
Ultra Champion

See if this works for you :

... | stats values(level) as levels by sessionId,userId | dedup userId | stats last(levels) as "last session" by userId,sessionId
0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...