Splunk Enterprise Security

calculate the difference between current time and Last event time and then display the difference in days

staparia
Explorer

I have the below query to calculate events not reporting for last 24 hours. I want to calculate the difference between current time and Last event time and then display the difference in days. This is the query i have. Somehow it diff field is empty. Please help

| metadata type=sourcetypes index=*
| search sourcetype!=*too_small
| where lastTime < (now() - 86400)
| convert ctime(lastTime) as Last_Time timeformat="%Y/%m/%d %H:%M" | eval diff=tostring(now() - Last_Time,"duration")
| fields sourcetype Last_Time diff
| sort -Last_Time

0 Karma
1 Solution

to4kawa
Ultra Champion
| metadata type=sourcetypes index=*
| search sourcetype!=*too_small
| where lastTime < (now() - 86400)
| eval diff=tostring(now() - lastTime,"duration")
| fields sourcetype lastTime diff
| sort - lastTime
|eval lastTime = strftime(lastTime,"%Y/%m/%d %H:%M" )

you should change time format at last.

View solution in original post

0 Karma

to4kawa
Ultra Champion
| metadata type=sourcetypes index=*
| search sourcetype!=*too_small
| where lastTime < (now() - 86400)
| eval diff=tostring(now() - lastTime,"duration")
| fields sourcetype lastTime diff
| sort - lastTime
|eval lastTime = strftime(lastTime,"%Y/%m/%d %H:%M" )

you should change time format at last.

0 Karma
Get Updates on the Splunk Community!

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

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...