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!

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...