Dashboards & Visualizations

Pass Time input value as default to another time input

santosh_sshanbh
Path Finder

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

santosh_sshanbh
Path Finder

skoelpin
SplunkTrust
SplunkTrust

Pass the token inline of the search like this

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

santosh_sshanbh
Path Finder

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

dmarling
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.

If this comment/answer was helpful, please up vote it. Thank you.
0 Karma

santosh_sshanbh
Path Finder

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

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...