Splunk Search

How to get the time difference after converting unix time using strftime?

payton_tayvion
Path Finder

I'm currently trying to get the duration of some events, but when i use this search nothing is coming back:

| tstats count earliest(_time) AS first latest(_time) as last FROM datamodel=Vulnerabilities where (nodename="Vulnerabilities" Vulnerabilities.severity!="informational") by Vulnerabilities.signature
| eval first_time=strftime(first,"%Y-%m-%d %H:%M:%S") , last_time=strftime(last,"%Y-%m-%d %H:%M:%S")
| fields - first,last
|eval duration=last_time-first_time

The strftime command converts the unix time, but im not able to get the difference

0 Karma

adonio
Ultra Champion

maybe change the order:

| tstats count earliest(_time) AS first latest(_time) as last FROM datamodel=Vulnerabilities where (nodename="Vulnerabilities" Vulnerabilities.severity!="informational") by Vulnerabilities.signature 
| eval duration=last - first
| eval first_time=strftime(first,"%Y-%m-%d %H:%M:%S") , last_time=strftime(last,"%Y-%m-%d %H:%M:%S") 
| fields - first,last duration
0 Karma

payton_tayvion
Path Finder

when i do it that way and convert the duration, the results are dates thats in 1970s vs it actually being the duration of the first and last time.

0 Karma
Get Updates on the Splunk Community!

Splunk Platform | Upgrading your Splunk Deployment to Python 3.9

Splunk initially announced the removal of Python 2 during the release of Splunk Enterprise 8.0.0, aiming to ...

From Product Design to User Insights: Boosting App Developer Identity on Splunkbase

co-authored by Yiyun Zhu & Dan Hosaka Engaging with the Community at .conf24 At .conf24, we revitalized the ...

Detect and Resolve Issues in a Kubernetes Environment

We’ve gone through common problems one can encounter in a Kubernetes environment, their impacts, and the ...