Splunk Search

Extract the 2nd event time in a transaction

ICAP_RND
Engager

When using transaction, SPLUNK always use _time of the 1st event
I need to extract the time of the second event in a transaction
I tried to use Time=_time+duration, however the result sometimes is not accurate
I have used the following transaction command:
index=clientlogs FailedApp=* OR "WorkflowServer.CloseApplication * pid:" 4104 | rex field=Message.Text "pid: (?\d+)"| transaction AppPID host startswith="WorkflowServer.CloseApplication * pid:" endswith="Application * failed" maxspan=60s mvlist=t| eval Time=_time+duration | eval date = strftime(Time, "%Y-%m-%d %H:%M:%S.%2N")
1st event time: 2017-01-07 11:01:13.10
2nd event time: 2017-01-07 11:01:16.39
duration: 2.39 sec
The sum result is: 2017-01-07 11:01:16.40

  1. Is there a better way to extract the second event timestamp?
  2. If not, is there a way to fix this issue?

see results in the attached file
alt text

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You can always run strptime() on the nth multivalue-member of the Message.Date field to parse its timestamp after the transaction.

View solution in original post

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You can always run strptime() on the nth multivalue-member of the Message.Date field to parse its timestamp after the transaction.

0 Karma

ICAP_RND
Engager

The best workaround is as follows:
index=clientlogs FailedApp=* OR "WorkflowServer.CloseApplication * pid:" | rex field=Message.Text "pid: (?\d+)"| transaction AppPID host startswith="WorkflowServer.CloseApplication * pid:" endswith="Application * failed" maxspan=60s mvlist=t | convert timeformat="%Y-%m-%d %H:%M:%S.%2N" mktime(Message.Date) as Date | eval DD=strftime(mvindex(Date,1), "%Y-%m-%d %H:%M:%S.%2N")

but if someone has an answer to my questions above, I'll be glad to know

0 Karma

somesoni2
Revered Legend

I've see the _time value being rounded up some times and that's what is showing it there (milliseconds being rounded off). See if this helps in the query that you've in your question

... | eval Time=_time+duration*1.00000 |...

Also, for your current working solution can be simplified as this (as the format of date is same in convert and strftime)

index=clientlogs FailedApp= OR "WorkflowServer.CloseApplication pid:" | rex field=Message.Text "pid: (?<AppPID>\d+)"| transaction AppPID host startswith="WorkflowServer.CloseApplication pid:" endswith="Application failed" maxspan=60s mvlist=t | eval DD=mvindex('Message.Date',1)

ICAP_RND
Engager

Thanks Martin
This workaround works
However, I want to know if I can use a direct method to extract the second event timestamp, and if not why duration is not working all the time

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...