Splunk Search

How do I find the time difference between these two events?

tomaszwrona
Explorer

Hello,

I have following events:

event 1:

product_category=dvd
product_name="the martian"
event=to_basket
event_time=2016-01-18T19:57:21+0100
...

event2:

product_category=dvd
product_name="the martian"
event=sold
event_time=2016-01-18T20:15:21+0100
...

How can I tell the time difference between 'to_basket' and 'sold' based on product_category and product_name?

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try something like this

your base search giving above two type of events i.e. event=to_basket OR event=sold | stats values(event_time) as event_time values(event) as event by product_category, product_name | eval Diff=strptime(mvindex(event_time,0),"%Y-%m-%dT%H:%M:%S%z")-strptime(mvindex(event_time,-1),"%Y-%m-%dT%H:%M:%S%z")

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Try something like this

your base search giving above two type of events i.e. event=to_basket OR event=sold | stats values(event_time) as event_time values(event) as event by product_category, product_name | eval Diff=strptime(mvindex(event_time,0),"%Y-%m-%dT%H:%M:%S%z")-strptime(mvindex(event_time,-1),"%Y-%m-%dT%H:%M:%S%z")

tomaszwrona
Explorer

Perfect, thank you!

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