Dashboards & Visualizations

how to write relative_time(now(),"$Value$") in the query..

vijaykumartcs
Explorer

I'm using summary index to capture all previous days and regular index to capture today's data to improve performance. I'm taking the earliest & latest timestamp of regular index.. Timerange token is added.
Now i want to set a token for SIearliest & SILatest using regular index timestamp.
eg: if searching for last 7days, instead of "+6days" i need a variable which should automatically check and change when i search for last 30days next time.

|eval SIEarliest = $time_range$ (earliesttimestamp) +)
|eval SILatest = $time_range$ + )

my search:
index=regular sourcetype=ABC
| chart earliest(_time) as RIEarliest latest(_time) as RILatest
|eval SIEarliest = $time_range$ + relative_time(now(),"-6d@d")
|eval SILatest = $time_range$ + relative_time(now(),"-d@d")
| appendpipe [ stats count | eval EarliestTime=0 | eval LatestTime= 0 | where count=0 | table RIEarliest RILatest SIEarliest SILatest ]

0 Karma

DalJeanis
Legend

It seems like you are really looking for the command addinfo and the fields info_min_time and info_max_time (the time range of the search).

Take a look here -

https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Addinfo

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

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 ...