Dashboards & Visualizations
Highlighted

Pass Time input value as default to another time input

I have 2 Time inputs on a single dashboard. MY requirement is to pass the value selected for 1st Time input as a default value for 2nd Time input. I tried to use $First_Time.earliest$ for the earliest parameter of 2nd time input but nothing is working for me.

Is there any way to achieve this?

0 Karma
Highlighted

Re: Pass Time input value as default to another time input

Builder

The below xml will accomplish this on initial page load, but after that it's all bets are off. I don't really understand why you need to do this but it will work:

<form>
  <label>Double Time inputs</label>
  <fieldset submitButton="false">
    <input type="time" token="timetok1">
      <label>time input 1</label>
      <default>
        <earliest>-7d@w0</earliest>
        <latest>@w0</latest>
      </default>
    </input>
    <input type="time" token="timetok2">
      <label></label>
      <default>
        <earliest>$timetok1.earliest$</earliest>
        <latest>$timetok1.latest$</latest>
      </default>
    </input>
  </fieldset>
</form>

On page load it will default the second time input with whatever is in the first time input as long as you don't have the second token timetok2 in the url. If you change the first time input after that point or if you have the timetok2 defined in the url as anything other than form.timetok2.earliest=%24timetok1.earliest%24&form.timetok2.latest=%24timetok1.latest%24, it will ignore whatever is in the first time field.

0 Karma
Highlighted

Re: Pass Time input value as default to another time input

This approach I have tried and its not working. I have extended your code by adding a panel to show count of events by sourcetypes. However, I am getting error ' Invalid earliest_time.' at load as well as when date time changes in input 1.

Double Time inputs

<input type="time" token="timetok1">
  <label>time input 1</label>
  <default>
    <earliest>-7d@w0</earliest>
    <latest>@w0</latest>
  </default>
</input>
<input type="time" token="timetok2">
  <label>time input 2</label>
  <default>
    <earliest>$timetok1.earliest$</earliest>
    <latest>$timetok1.latest$</latest>
  </default>
</input>


<panel>
  <table>
    <search>
      <query>index=* | stats count(8) by sourcetype</query>
      <earliest>$timetok2.earliest$</earliest>
      <latest>$timetok2.latest$</latest>
    </search>
    <option name="drilldown">none</option>
    <option name="refresh.display">progressbar</option>
  </table>
</panel>
0 Karma
Highlighted

Re: Pass Time input value as default to another time input

SplunkTrust
SplunkTrust

Pass the token inline of the search like this

index=... earliest=$First_Time.earliest$ latest=$First_Time.earliest$
0 Karma
Highlighted

Re: Pass Time input value as default to another time input

Basically I have a dril down functionality on my dashboard. The first Time input will be visible at load. And 2nd will be visible on drill down. And the default value for 2nd Time input I want to pass the current selected value for 1st Time input.

The drill down search is tied to earliest and latest time range of 2nd Time input.

0 Karma
Highlighted

Re: Pass Time input value as default to another time input

0 Karma
Speak Up for Splunk Careers!

We want to better understand the impact Splunk experience and expertise has has on individuals' careers, and help highlight the growing demand for Splunk skills.