Getting Data In

How to change the displayed time filter when a different dropdown value is selected?

I have two filters on my dashboard. One for time (using the Time filter) and one for environment (using the Dropdown filter). When I select a value from environment, it updates the time token and the dashboard panels correctly. However, it does not change the displayed value in the time filter dropdown.

For example: The dashboard defaults to Environment: Test and Time: Last 60 Minutes. If I change the Environment to Prod, then it changes the Time to Last 24 Hours, but the dropdown does not reflect that, which is confusing.

How do I get the text in the time dropdown to update when I select a value from another dropdown?

  <init>
    <set token="index">test</set>
    <set token="time"> -60m@m</set>
  </init>
  <label>Test Dashboard</label>
  <description>Test description.</description>
  <fieldset submitButton="false">
    <input type="time" token="time">
      <label>Time-Picker</label>
      <default>
        <earliest>-60m@m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="index" searchWhenChanged="true">
      <label>Environment</label>
      <choice value="prod">Prod</choice>
      <choice value="test">Test</choice>
      <default>test</default>
      <change>
        <condition label="Test">
          <set token="spacename">cf_space_name="development"</set>
          <set token="time">-60m@m</set>
        </condition>
        <condition label="Prod">
          <set token="spacename">cf_space_name="production"</set>
          <set token="time">@d</set>
        </condition>
      </change>
    </input>
  </fieldset>
0 Karma
1 Solution

Motivator

Try changing <set token="time"> to <set token="form.time.earliest">. I figured it out by looking at the values in the URL when changing the time directly. You'll also want to change it in your <init> setting. Here's a run-anywhere dashboard:

<form>
  <init>
    <set token="index">test</set>
    <set token="form.time.earliest">-60m@m</set>
  </init>
  <fieldset submitButton="false">
    <input type="time" token="time" searchWhenChanged="true">
      <label>Time Picker</label>
      <default>
        <earliest>-15m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="index" searchWhenChanged="true">
      <label>Environment</label>
      <choice value="prod">Prod</choice>
      <choice value="test">Test</choice>
      <default>test</default>
      <change>
        <condition label="Test">
          <set token="spacename">cf_space_name="development"</set>
          <set token="form.time.earliest">-60m@m</set>
        </condition>
        <condition label="Prod">
          <set token="spacename">cf_space_name="production"</set>
          <set token="form.time.earliest">@d</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <html>
      $time$ --- $form.time.earliest$ --- $spacename$ 
    </html>
  </row>
  <row>
    <panel>
      <event>
        <search>
          <query>index=_internal</query>
          <earliest>$time.earliest$</earliest>
          <latest>$time.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">50</option>
        <option name="list.drilldown">none</option>
        <option name="list.wrap">1</option>
        <option name="maxLines">5</option>
        <option name="raw.drilldown">full</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">0</option>
        <option name="table.drilldown">all</option>
        <option name="table.sortDirection">asc</option>
        <option name="table.wrap">1</option>
        <option name="type">list</option>
      </event>
    </panel>
  </row>
</form>
Cheers,
Jacob

View solution in original post

Motivator

Note the typo here: <set token="time"> -60m@m</set> (the space before the '-' sign)

Cheers,
Jacob

Thanks for pointing that out! I didn't even notice.

0 Karma

Motivator

Try changing <set token="time"> to <set token="form.time.earliest">. I figured it out by looking at the values in the URL when changing the time directly. You'll also want to change it in your <init> setting. Here's a run-anywhere dashboard:

<form>
  <init>
    <set token="index">test</set>
    <set token="form.time.earliest">-60m@m</set>
  </init>
  <fieldset submitButton="false">
    <input type="time" token="time" searchWhenChanged="true">
      <label>Time Picker</label>
      <default>
        <earliest>-15m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="index" searchWhenChanged="true">
      <label>Environment</label>
      <choice value="prod">Prod</choice>
      <choice value="test">Test</choice>
      <default>test</default>
      <change>
        <condition label="Test">
          <set token="spacename">cf_space_name="development"</set>
          <set token="form.time.earliest">-60m@m</set>
        </condition>
        <condition label="Prod">
          <set token="spacename">cf_space_name="production"</set>
          <set token="form.time.earliest">@d</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <html>
      $time$ --- $form.time.earliest$ --- $spacename$ 
    </html>
  </row>
  <row>
    <panel>
      <event>
        <search>
          <query>index=_internal</query>
          <earliest>$time.earliest$</earliest>
          <latest>$time.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">50</option>
        <option name="list.drilldown">none</option>
        <option name="list.wrap">1</option>
        <option name="maxLines">5</option>
        <option name="raw.drilldown">full</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">0</option>
        <option name="table.drilldown">all</option>
        <option name="table.sortDirection">asc</option>
        <option name="table.wrap">1</option>
        <option name="type">list</option>
      </event>
    </panel>
  </row>
</form>
Cheers,
Jacob

View solution in original post

This worked perfectly! Thank you so much!

Motivator

You're welcome. Thanks for marking the answer!

Cheers,
Jacob
0 Karma
Don’t Miss Global Splunk
User Groups Week!

Free LIVE events worldwide 2/8-2/12
Connect, learn, and collect rad prizes
and swag!