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!

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