Splunk Search

duration of two consecutive log statement

firasarabo
Path Finder

Hi,

I tried to use "transaction" command but I couldn't get what I wanted, I thought to ask the question here if somebody can give hint/solution

so I do have an application that output logs as follows

2012-08-23 19:36:19,612 INFO THR_ID=729108133 some message

2012-08-23 19:36:21,612 INFO THR_ID=729108133 some message

2012-08-23 19:36:22,612 INFO THR_ID=729108133 some message

2012-08-23 19:36:25,612 INFO THR_ID=729108133 some message

etc

I would like to write a search that gives me the duration between each two logging lines for the saem THR_ID, so in this scenario I should see somthing like

Duration
2

1

3

any ideas how to accomplish this?

Thanks,
Firas

Tags (1)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

Sure,

I looks like you should check the delta command, and use it on the built-in _time field. Something like this.

your_search | sort THR_ID, _time| delta _time as t_diff | table t_diff, THR_ID, whatever_else_you_want_to_show_from_the_event

UPDATE: forgot that you'd need to sort on THR_ID in order to get correct results. Oops. Fixed that.

Hope this helps,

Kristian

View solution in original post

kristian_kolb
Ultra Champion

Sure,

I looks like you should check the delta command, and use it on the built-in _time field. Something like this.

your_search | sort THR_ID, _time| delta _time as t_diff | table t_diff, THR_ID, whatever_else_you_want_to_show_from_the_event

UPDATE: forgot that you'd need to sort on THR_ID in order to get correct results. Oops. Fixed that.

Hope this helps,

Kristian

firasarabo
Path Finder

thanks, the delta will get me what I wanted.

0 Karma

kristian_kolb
Ultra Champion

updated /k

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

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...