Splunk Search

how to set epoch value to

reney44
Engager

i find epoch time from my token $date1$ using below code
index="cdq-dashboard-dev"|eval earliest="$date1$"| convert timeformat="%Y-%m-%d" mktime("earliest")|convert num("earliest")|eval latest=earliest+86400|convert num("latest")|eval earliest-time=tostring(earliest)|eval latest-time=tostring(latest)|dedup earliest-time |table earliest,latest,latest-time,earliest-time

then get the epoch vale in string as well as number.
i want to filter using epoch value like below but its not working
$epoch_earliest$
$epoch_latest$

but its not working

Tags (3)
0 Karma

woodcock
Esteemed Legend

This is a mess; you are doing WAY too much work. Try using fieldformat which causes the value to present to you formatted but retains the unformatted value underneath (so that you can do math and comparisons):

index="cdq-dashboard-dev"|eval earliest="$date1$"
| bin earliest span=1d
| dedup earliest 
| eval latest = earliest + 86400
| fieldformat  earliest = strftime(earliest, "%Y-%m-%d")
| fieldformat  latest = strftime(latest, "%Y-%m-%d")
| table earliest latest
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 ...