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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...