Dashboards & Visualizations

How to display active/selected time range?

petenetwork
Explorer

I can create a Splunk query using earliest and latest fields, e.g.:

earliest=-7d latest=-1d index=os * |head 1

What I want is to put that calculated earliest time into a variable, e.g.

|eval StartedFrom=strftime( earliest, "%Y-%m-%d" )

... but this doesn't work.

How can I store the boundary of the search period into a variable?


UPDATE: @HiroshiSatoh provided the answer. My working query now looks like:

 |makeresults
    |addinfo
    |eval result="earliest=" . strftime(info_min_time,"%m/%d/%Y:%H:%M:%S") . " latest=" . strftime(info_max_time,"%m/%d/%Y:%H:%M:%S")
    |table result

This is extremely useful because I can put this into a dashboard and then cut-and-paste the earliest/latest modifiers into any other queries I make while narrowing into an interesting time period.

Note that because this query does not rely on any actual search a dummy value can be created by prefixing the query with |makeresults.

0 Karma
1 Solution

HiroshiSatoh
Champion
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

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