Splunk Enterprise Security

Find Latency in Days

bmer
Explorer

I have a splunk where one of the eval method as part of main splunk query is as below.Iam not sure why SnapshotTimestamp is divided by 1000 but I presume it could be done to convert it to seconds.Sorry am a newbie

| eval snapshot_processed = strftime(SnapshotTimestamp/1000, "%Y-%m-%d %H:%M:%S")



Iam trying to find the # of days clasped between "snapshot_processed" and today. I tried to modify the splunk as below and then try to view the table for "latencyInDays".However it does not return any value.

| eval nowstring=now()
| eval latencyInDays=(nowstring-snapshot_processed)/86400

 

 What am I missing?

Labels (1)
0 Karma
1 Solution

livehybrid
SplunkTrust
SplunkTrust

Hi @bmer 

Is your SnapshotTimestamp in milliseconds? Im assuming so because you're dividing by 1000.

You should be able to do this:

| eval latencyInDays=floor((now()-(SnapshotTimestamp/1000)) / 86400)

 Here is a full example to test with:

| makeresults 
| eval SnapshotTimestamp=1741788339000
| eval latencyInDays=floor((now()-(SnapshotTimestamp/1000)) / 86400)

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The query is mixing strings (snapshot_processed) with integers (nowstring), which Splunk cannot do.  Try this

| eval latencyInDays=(now() - SnapshotTimestamp/1000)/86400
---
If this reply helps you, Karma would be appreciated.

livehybrid
SplunkTrust
SplunkTrust

Hi @bmer 

Is your SnapshotTimestamp in milliseconds? Im assuming so because you're dividing by 1000.

You should be able to do this:

| eval latencyInDays=floor((now()-(SnapshotTimestamp/1000)) / 86400)

 Here is a full example to test with:

| makeresults 
| eval SnapshotTimestamp=1741788339000
| eval latencyInDays=floor((now()-(SnapshotTimestamp/1000)) / 86400)

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

dural_yyz
Motivator
| eval duration = tostring(diff, "duration")

This will output Days & Clock type output.

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Usually when you are using 1000 with divider and/or multiplier, there have done conversion between ms and s and vice versa.
86400 is 24h in seconds

It's hard to say more without seeing your data/values on those fields.

One way to see it is use 

| eval latencyInDays = tostring(latencyInSeconds, "duration")

and if you want to just show it in screen but keep value still in seconds just replace eval with fieldformat. 

r. Ismo

0 Karma
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.


Introducing Unified TDIR with the New Enterprise Security 8.2

Read the blog
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...