Dashboards & Visualizations

how to format and use time picker values in panel title?

stwong
Communicator

Hi, is it possible to format time picker value, e.g. $earliest$ and $latest$, in panel title? If i do something like this:

 <title>Total access for department $d_name$ between $earliest$ and $latest$</title>

It gives raw time format, or the relative values like -4d@d. We hope to print the values in yyyymmdd HH:MM:SS in title. Please help.

Thanks a lot.

/ST Wong

0 Karma
1 Solution

gokadroid
Motivator

Can you first try to evaluate the string you are interested in as tokens using eval and then use those tokens in the title. Say the token of your timepicker is myTimepicker then try something like this and see if it works out:

<eval token="fromDate">strftime($myTimepicker.earliest$,"%Y%m/%d %H:%M:%S")</eval>
<eval token="toDate">strftime($myTimepicker.latest$, "%Y%m/%d %H:%M:%S")</eval>

And then later use $fromDate$ and $toDate$ in the panel title.

View solution in original post

0 Karma

stwong
Communicator

Hi all,

Thanks for your help. Both ways work with custom time range is selected. However, strftime doesn't understand relative time specifiers like -30m@m, which is used quite frequently by our users.

Thanks again.

0 Karma

aaraneta_splunk
Splunk Employee
Splunk Employee

@stwong - It looks like you found a solution to your question? If one of them provided a working solution, please don't forget to click "Accept" below the best answer to resolve this post so that it can easily be found by other users in the same situation. Don’t forget to upvote anything that was helpful too. Thanks!

0 Karma

stwong
Communicator

Got it. Thanks.

0 Karma

gokadroid
Motivator

You are welcome!

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try this runanywhere sample

<form>
  <label>TobeDeleted</label>
  <fieldset submitButton="false">
    <input type="time" token="timerange" searchWhenChanged="true">
      <label>Time Range</label>
      <default>
        <earliest>-15m</earliest>
        <latest>now</latest>
      </default>
      </input>
  </fieldset>
  <search>
        <query>| gentimes start=-1 | addinfo </query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
        <done>
          <eval token="Tearliest">strftime($result.info_min_time$,"%F %T")</eval>
          <eval token="Tlatest">strftime($result.info_max_time$,"%F %T")</eval>
        </done>
      </search>
  <row>
    <panel>
      <table>
        <title>Showing data between $Tearliest$ and $Tlatest$</title>
        <search>
          <query>|gentimes start=-1 | eval Message="Dummy Panel" | table Message </query>
          <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
        </search>
        <option name="wrap">true</option>
        <option name="rowNumbers">false</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">row</option>
        <option name="count">10</option>
      </table>      
    </panel>
  </row>
</form>

gokadroid
Motivator

Can you first try to evaluate the string you are interested in as tokens using eval and then use those tokens in the title. Say the token of your timepicker is myTimepicker then try something like this and see if it works out:

<eval token="fromDate">strftime($myTimepicker.earliest$,"%Y%m/%d %H:%M:%S")</eval>
<eval token="toDate">strftime($myTimepicker.latest$, "%Y%m/%d %H:%M:%S")</eval>

And then later use $fromDate$ and $toDate$ in the panel title.

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