Splunk Search

How do I edit my search to get stats on new users (1 user session) and return users (2+ different user sessions) for a given time period?

spammenot66
Contributor

My logs currently capture username and a session id. Keep in mind that 1 session can have multiple hits to different pages or activities.

My definition for users:
new user = users with 1 user session for a given time period
return user = users with more than 1 different user session for a given time period

Is there a way to get new vs return user stats into a pivot table? Is there an easier way to get this detail than the search below?

| dedup user, session
| stats count by user
| eval newuser = if(count =1,1,0) 
| eval returnuser = if(count =1,0,1) 
|stats sum(newuser) as "New User", sum(returnuser) as "Return User"
0 Karma
1 Solution

renjith_nair
Legend

Try this

dedup user, session|eventstats count by user|stats sum(eval(count >1)) as old,sum(eval(count == 1)) as new
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

somesoni2
Revered Legend

Try something like this

your base search | stats dc(session) as dc by user | stats count(eval(dc =1)) as "New User" count(eval(dc >1)) as "Return User"

renjith_nair
Legend

Try this

dedup user, session|eventstats count by user|stats sum(eval(count >1)) as old,sum(eval(count == 1)) as new
---
What goes around comes around. If it helps, hit it with Karma 🙂

spammenot66
Contributor

both works for me. its a shame they can't fit into a data model. It would've been cool to use in a pivot table. Thanks again.

0 Karma

ppablo
Retired

Hi @spammenot66

Glad you were able to find 2 working answers for your question. Can you please resolve the post by clicking "Accept" directly below the answer that best answered your question (or the one you decided to use)? This will make the question and answers easier to find for other users. Thanks!

Patrick

0 Karma

spammenot66
Contributor

@ppablo - thanks for the info.

0 Karma
Get Updates on the Splunk Community!

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

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...