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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...