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!

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 ...