Splunk Search

how to calculate starttime and Endtime duration

babukumarreddy
Loves-to-Learn Lots

how to calculate starttime and Endtime duration

|08-feb-2019 01:30:18|08-feb-2019 01:30:28

Tags (1)
0 Karma

chrisyounger
SplunkTrust
SplunkTrust

Try this: |eval d1 = strptime(starttime, "%d-%b-%Y %H:%M:%S") | eval d2 = strptime(endtime, "%d-%b-%Y %H:%M:%S") | eval duration_in_seconds = d1 - d2

Hope this helps

0 Karma

pkarpushin
Path Finder

Hi @babukumarreddy ,

If I get correctly whay you mean, you have a set of events and you need to calculate the time delta between the earliest and latest event.
You could use stast command:

<your main search here> | stats first(_time) as End, last(_time) as Start | eval Duration=End-Start | ....

But it would be better if you give more detailed description of your goal.

0 Karma

babukumarreddy
Loves-to-Learn Lots

Hi Pkarpushin

actually iam new to splunk

in my logs starttime and endtime is there need to calculate duration
starttime endtime
|08-feb-2019 01:30:18|08-feb-2019 01:30:28

fieldnames are starttime and endtime

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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

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, ...