Getting Data In

Timediffrence between two different events

venksplunk1
Loves-to-Learn

Hi All,

I have two different search criteria & query. First search criteria/query will produce the start time for event 1 and second search criteria/query will be provide End time for event1. Need to calculate the duration between Start and End time using Splunk.

Labels (1)
0 Karma

venksplunk1
Loves-to-Learn

Time Stamp Format for Start and End Time as follows: 2021-08-24T04:31:32.245+00:00

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

for individual event you can try this one:

index=XX cf_org_name=YY event_type=LogMessage cf_app_name="*-Envtname*" 
| spath "msg.message" 
| search "msg.message"="*ProductID*" 
| spath "msg.message" 
| search "msg.message"!="*ACTIVITY.LOG.IMPORTS*" 
| spath "msg.level" 
| spath cf_app_name 
| search cf_app_name="*Servicename*" 
| spath "msg.message" 
| search "msg.message"="*Request Initiated*" OR "msg.message"="*Request Fulfilled*"
| rename msg.@timestamp as EventStartTime,  msg.@timestamp as EventEndTIme
| eval sTime = strptime(EventStartTime, "%Y-%m-%dT%H:%M:%S.%3Q%:z"), eTime = strptime(EventEndTime, "%Y-%m-%dT%H:%M:%S.%3Q%:z")
| eval dTime = eTime - sTime, duration = tostring(dTime, "duration")
| table cf_app_name, EventStartTime, EventEndTime, duration, msg.message

For several events it could be better to use streamstats etc?

r. Ismo 

0 Karma

venksplunk1
Loves-to-Learn

Thanks for your reply.

My First query as follows: It will capture the EventStartTime

index=XX cf_org_name=YY event_type=LogMessage cf_app_name="*-Envtname*" | spath "msg.message" | search "msg.message"="*ProductID*" | spath "msg.message" | search "msg.message"!="*ACTIVITY.LOG.IMPORTS*" | spath "msg.level" | spath cf_app_name | search cf_app_name="*Servicename*" | spath "msg.message" | search "msg.message"="*Request Initiated*"  rename msg.@timestamp as EventStartTime |table cf_app_name,   EventStartTimemsg.message

 

My Second query as follows: It will capture the EventEndTime

index=XX cf_org_name=YY event_type=LogMessage cf_app_name="*-Envtname*" | spath "msg.message" | search "msg.message"="*ProductID*" | spath "msg.message" | search "msg.message"!="*ACTIVITY.LOG.IMPORTS*" | spath "msg.level" | spath cf_app_name | search cf_app_name="*Servicename*" | spath "msg.message" | search "msg.message"="*Request Fulfilled*"  rename msg.@timestamp as EventEndTIme |table cf_app_name,   EventEndTimemsg.message

 

As of now, I have executed my first and second queries sequentially and able to capture the start and end time. Need to capture the Start and End time in parallel and measure the difference between Start and End time. Duration=EventEndTime-EventStartTIme.

Would it be possible to help me here? Let me know if you are need of any additional details.

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

there are some different ways to do this based on your data. Can you give a sample data to us, so we could easier show the possibilities for your case?

There is already quite many answers for this questions on community, so you could try to found those also.

r. Ismo

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

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