Splunk Search

How to write a search to calculate the average length of sessions by time?

dgravesa1
New Member

Hi New to Splunk:

Trying to calculate average session lengths ( in time ) for sessions that have failed. And one for sessions that are successful. Below is what i have put together:

index=CCTV streaming_realm=* SessionFailed | bucket span=1m _time | dedup device_id, requested_deliverable | search SessionID="*" | stats range(_time) AS Session_Duration_sec by SessionID | stats avg(Session_Duration_Sec)
Tags (3)
0 Karma

somesoni2
Revered Legend

Try this

index=CCTV streaming_realm=* SessionFailed | stats range(_time) as duration by SessionID | stats avg(duration) as Avg_Session_Duration_Sec

OR

index=CCTV streaming_realm=* SessionFailed | transaction SessionID | stats avg(duration) as Avg_Session_Duration_Sec
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...