Splunk Search

Delta time for each event for basic search?

abzmhzsplunk
New Member

If I run a simple search:
Index=*

It displays each event with columns as time, then the event.

Is there a way to configure Splunk also to display another column called "Delta Time" which shows time difference from previous event?

This will help to eyeball quickly the time gap.

Thanks.

Tags (2)
0 Karma

lguinn2
Legend

Yes you can, although this can add quite a bit of overhead to your search, depending on the number of results. And the search "index=*" is also an expensive search, unless you are in a small environment or your timerange is very short.

index=*
| delta _time p=1 as delta_time
| eval delta_time = tostring(delta_time,"duration")
| table _time, delta_time, _raw

Notice that your delta time will always be negative, because Splunk shows the most recent events first.

(Updated to correct typo in line 3 of the search)

0 Karma

abzmhzsplunk
New Member

Thanks for posting the answer.

In the above posting, I removed line 3 which caused error.

index=* My_TXN_ID
| delta _time p=1 as delta_time
| table _time, delta_time, _raw

Now it works.

Is there a way to also display the sequence number, and show the message not as "_raw" but formatted as normal search result?

Thanks.

0 Karma

abzmhzsplunk
New Member

Ok, I know how to add sequence number.
How to format the message "_raw" as normal search display?

index=* My_TXN_ID
| delta _time p=1 as delta_time

|streamstats count as seq_num
| table seq_num _time, delta_time, _raw

0 Karma

lguinn2
Legend

I don't know what you mean by "normal search display."
_raw represents the entire event. It is unusual to use _raw in the table command. Instead, include a list of the fields of interest. I can't tell you what fields that would be, since it depends entirely on your data. But for example:

... | table seq_num _time delta_time host status message
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Splunk Observability Metrics Cost Optimization

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...