Dashboards & Visualizations

Is there a function to turn a time range into human-readable string?

unitedmarsupial
Path Finder

I've created a dashboard with a shared "time-input" (named range) -- all of the panels refer to it:

      <earliest>$range.earliest$</earliest>
      <latest>$range.latest$</latest>

I'd like each panel's title to reflect the currently-picked range -- showing it in human-readable form like "Last 4 hours" or "Yesterday from 2am to 3am". Is this possible?

Update: Ok, I found I can add something like this to the titles:

... between $range.earliest$ and $range.latest$

and it will be translated to, for example between -7d@h and now. Maybe, there are better alternatives?..

0 Karma

vnravikumar
Champion

Hi

Check this

<input type="time" searchWhenChanged="true">
        <label>Enter the time range</label>
        <default>
          <earliest>-1d@d</earliest>
          <latest>@d</latest>
        </default>
        <change>
          <set token="displayTime">($label$)</set>
        </change>
      </input>

to4kawa
Ultra Champion

It is enough to use in the Last something.
If Today is specified, it is regrettable that it will be Custom time.

0 Karma

to4kawa
Ultra Champion
| makeresults 
| addinfo 
| eval _time=info_max_time 
| reltime 
| rename reltime as last_time 
| eval _time=info_min_time 
| reltime 
| rename reltime as first_time
| eval output_text="Search period: between ".first_time." to ".last_time

you can hide the panel and pass output_text in tokens.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Check out the reltime function.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...