Splunk Search

Transaction command - Way to change from timestamp to a different field?

Maycockk
Explorer

Good morning all,

I'm leveraging the transaction command in order to gather statistics around the duration of my requests in order to report on them. By default the transaction command leverages the _time field (timestamp) to calculate the duration for the transaction. However, the issue I'm facing is the timestamp appear to have intermittent jumps in it that's skewing my numbers. I'd assume it's just forwarded config perhaps.

I do have a second, more accurate, timestamps available to me that I'd like to leverage "ServerTime" which has been added to our events. I'm just trying to understand if I can override the transaction command to use the ServerTime field I have rather than the timestamp?

See attached screenshots demonstrating the issue. Thx in advance everyone  🙂

 

Labels (1)
0 Karma
1 Solution

nickhills
Ultra Champion

You can rewrite "_time" to be a valid timestamp from your event data, and then the transaction command will use that value instead.

 

For example, if you have a field called ServerTime in the format "12/02/2020 09:32:24 AM":

 

 

index=main source=http:xxxx ServiceName=xxxx OR ServiceName=xxxx CorrelationID=xxxx |rex xxxxxxxx|eval _time=strptime(ServerTime,"%m/%d/%Y %I:%M:%S %p") |transaction RawCorrelationID |stats count by duration

 

 

If my comment helps, please give it a thumbs up!

View solution in original post

nickhills
Ultra Champion

You can rewrite "_time" to be a valid timestamp from your event data, and then the transaction command will use that value instead.

 

For example, if you have a field called ServerTime in the format "12/02/2020 09:32:24 AM":

 

 

index=main source=http:xxxx ServiceName=xxxx OR ServiceName=xxxx CorrelationID=xxxx |rex xxxxxxxx|eval _time=strptime(ServerTime,"%m/%d/%Y %I:%M:%S %p") |transaction RawCorrelationID |stats count by duration

 

 

If my comment helps, please give it a thumbs up!

Maycockk
Explorer

Perfect, worked a charm! Thank you kindly

0 Karma

Maycockk
Explorer

Here is a screenshot showing difference in _time timestamp however around same time as per ServerTime field we have available.

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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

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

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...