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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...