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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...