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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...