Splunk Search

Average Stats intervals

jasonmadesometh
Explorer

Hello,

I am trying to get around the inefficiency of the transaction command by using stats. My goal is to correlate user sessions and find the average duration of the session over given time frames (I suspect a dip may indicate a problem). The search I have so far appears to only work on hour intervals, is there any way to get it to parse on tighter spans? I couldn't seem to find a way to preserve _time for use with the timechart.

My search is as follows:

foo
| rename user_id as user
| eval dHour=strftime(_time, "%D %H") 
| stats count as eventCount earliest(_time) as earliestTime latest(_time) as latestTime by  dHour user
| eval duration=latestTime - earliestTime 
| stats avg(duration) as avgDuration sum(eventCount) as numEvents avg(eventCount) as avgEventsPerSession count(user) as numberOfUsers by dHour
|  where avgDuration<1600 AND numEvents>30000 AND avgEventsPerSession<100 AND numberOfUsers>12000
0 Karma
1 Solution

to4kawa
Ultra Champion
foo
 | rename user_id as user
 | eval time=_time
 | bin span=1h time
 | stats count as eventCount range(_time) as duration by  time user
 | stats avg(duration) as avgDuration sum(eventCount) as numEvents avg(eventCount) as avgEventsPerSession count(user) as numberOfUsers by time
 |  where avgDuration<1600 AND numEvents>30000 AND avgEventsPerSession<100 AND numberOfUsers>12000
 | rename time as _time

Check the result by changing the bin span= args.

View solution in original post

to4kawa
Ultra Champion
foo
 | rename user_id as user
 | eval time=_time
 | bin span=1h time
 | stats count as eventCount range(_time) as duration by  time user
 | stats avg(duration) as avgDuration sum(eventCount) as numEvents avg(eventCount) as avgEventsPerSession count(user) as numberOfUsers by time
 |  where avgDuration<1600 AND numEvents>30000 AND avgEventsPerSession<100 AND numberOfUsers>12000
 | rename time as _time

Check the result by changing the bin span= args.

Get Updates on the Splunk Community!

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

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

Splunk Education Goes to Washington | Splunk GovSummit 2024

If you’re in the Washington, D.C. area, this is your opportunity to take your career and Splunk skills to the ...