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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...