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!

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...

State of Splunk Careers 2024: Maximizing Career Outcomes and the Continued Value of ...

For the past four years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...

Data-Driven Success: Splunk & Financial Services

Splunk streamlines the process of extracting insights from large volumes of data. In this fast-paced world, ...