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 July Tech Talks, Office Hours, and Webinars!

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...