Splunk Search

calculate duration between multiple events from same session

sajids
New Member

I am dealing with log files which are structured as follows
TimeStamp=1 SessionHandle=1 SessionEvent=A
TimeStamp=2 SessionHandle=1 SessionEvent=B
TimeStamp=3 SessionHandle=1 SessionEvent=C
TimeStamp=4 SessionHandle=1 SessionEvent=D
TimeStamp=5 SessionHandle=1 SessionEvent=E
TimeStamp=6 SessionHandle=1 SessionEvent=F
TimeStamp=7 SessionHandle=1 SessionEvent=G
TimeStamp=8 SessionHandle=1 SessionEvent=H

TimeStamp=10 SessionHandle=2 SessionEvent=A
TimeStamp=11 SessionHandle=2 SessionEvent=B
TimeStamp=12 SessionHandle=2 SessionEvent=C
TimeStamp=13 SessionHandle=2 SessionEvent=D
TimeStamp=14 SessionHandle=2 SessionEvent=E
TimeStamp=15 SessionHandle=2 SessionEvent=F
TimeStamp=16 SessionHandle=2 SessionEvent=G
TimeStamp=17 SessionHandle=2 SessionEvent=H

I want to calculate duration between various events for each session
For ex: timediff between B & A, similarly H-A, H-D, A-F etc for each session separately and display results in single table

Tags (1)
0 Karma

somesoni2
SplunkTrust
SplunkTrust

You may use streamstats to achieve this. Try something like this

Your Base search | streamstats window=1 current=f first(TimeStamp) as prevTimeStamp | eval duration=prevTimeStamp-TimeStamp 
0 Karma

amitkr0201
Explorer

You can use transaction for this.

e.g. for calculating timediff between A & B, you can use something like

...|transaction SessionHandle startswith="SessionEvent=A" endswith="SessionEvent=B"

0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...