Dashboards & Visualizations

In my dashboard, I want to convert the time range chosen into seconds and display the value in a panel

moizmmz
Path Finder

Say I select a time range from 11:00:00 to 12:00:00 (1 hour), I want my panel to show the value in seconds of the duration of the time range. i.e., panel should show 3600 seconds. Please help!

Tags (1)
0 Karma

vishaltaneja070
Motivator

Hello @moizmmz

Try this:

<form>
  <label>test1</label>
  <fieldset submitButton="false">
    <input type="time" token="time_tok" searchWhenChanged="true">
      <label>Select Time</label>
      <default>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>$time1$</title>
      <single>
        <search>
          <done>
            <set token="time1">$result.time_in_sec$</set>
          </done>
          <query>| makeresults | eval latest1=if($time_tok.latest|s$ == "now", now(),$time_tok.latest|s$)  | eval earliest1 = if($time_tok.latest|s$ == "now", relative_time(now(), $time_tok.earliest|s$), $time_tok.earliest|s$)  | eval time_in_sec= latest1 - earliest1 | eval time_in_sec = time_in_sec -  (time_in_sec % 60) | fields + time_in_sec</query>
          <earliest>$time_tok.earliest$</earliest>
          <latest>$time_tok.latest$</latest>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </single>
    </panel>
  </row>
</form>
0 Karma

vnravikumar
Champion

Hi

Try this, seconds duration available in the token duration_sec. Modify accordingly

<form>
  <label>duration</label>
  <fieldset submitButton="false">
    <input type="time" token="timepicker">
      <label></label>
      <default>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </default>
      <change>
        <eval token="time.earliest_epoch">if(isnum('earliest'),'earliest',relative_time(now(),'earliest')</eval>
        <eval token="time.latest_epoch">if(isnum('latest'),'latest',relative_time(now(),'latest')</eval>
        <eval token="duration_sec">($time.latest_epoch$-$time.earliest_epoch$)</eval>
      </change>
    </input>
</fieldset>
<row>
  <panel>
    <title>Time duration in seconds:$duration_sec$</title>
    <single>
      <search>
        <query>
          |makeresults | eval duration=$duration_sec$
        </query>
      </search>
    </single>
  </panel>
</row>
</form>

somesoni2
Revered Legend

YOu want to show the current time range (value in total number of seconds) in a single value panel OR within existing panel (in title OR in the table itself)?

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...