Splunk Search

Using eval to create date in epoch time

hcannon
Path Finder

I need to create a field today that is equal to the epoch timestamp in milliseconds for midnight yesterday. I've been successful in using eval for this, but splunk is adding ".000" to the end of the field value and I can't for the life of me figure out why or how to remove .000, so that the value can be passed to a dbxquery formatted in milliseconds.

I've tried using rex mode=sed field=today "s/.000//", then attempted to convert the value to a string first, before sending to rex/sed.
The .000 persists.

...| eval today=(relative_time(now(),"-1d@d")*1000) | top today

search result:
today=1513832400000.000

Tags (2)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try this

..| eval today=round(relative_time(now(),"-1d@d")*1000) | top today

View solution in original post

micahkemp
Champion

Try

eval today=round(relative_time(now(), “-1d@d”) * 1000, 0)
0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try this

..| eval today=round(relative_time(now(),"-1d@d")*1000) | top today

hcannon
Path Finder

this did the trick, thank you!!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...