Splunk Search

How to get the time elapsed between these two fields?

Clecimar
Explorer

Guys, can you help me ?

I need to know the elapsed time between this two fields:

CREATED_TS: 20220816182818.215
CURRENT_TIMESTAMP: 20220816185516

Do you have a tip on how can do this ?

Thank you.

Clecimar

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

To compare two times in Splunk you must first convert them into epoch (integer) form.  Do that using the strptime function.

| eval created = strptime(CREATED_TS, "%Y%M%D%H%M%S.%3N")
| eval current = strptime(CURRENT_TIMESTAMP, "%Y%M%D%H%M%S")
| eval diff = current - created
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

To compare two times in Splunk you must first convert them into epoch (integer) form.  Do that using the strptime function.

| eval created = strptime(CREATED_TS, "%Y%M%D%H%M%S.%3N")
| eval current = strptime(CURRENT_TIMESTAMP, "%Y%M%D%H%M%S")
| eval diff = current - created
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...