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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...