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!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...