Dashboards & Visualizations

Can I set a timerange and region token on a dashboard?

New Member

I have a dashboard with 3 tokens

1) Timerange token
2) Region token
3) Submit button token

Now when i select the timerange and region token and click on submit button, it works for the first time, but when i change the timerange and region without clicking on submit button the data is showing in the dashboard.

Is there a way to fix it. can i set a token to submit button, so that i can use them in table/panel depends.

0 Karma

New Member
   <fieldset submitButton="true" autoRun="false">
     <input type="time" token="time_range" searchWhenChanged="false">
       <label>Display Range</label>
     <input type="dropdown" token="SetRegion" searchWhenChanged="false">
       <label>Select Region</label>
       <choice value="NY">NewYork</choice>
       <choice value="LN">London</choice>
         <condition value="NY">
           <set token="Region" >NYindex</set>
         <condition value="LN">
           <set token="Region">LNindex</set>
     <input type="link" token="unused" searchWhenChanged="false">
       <label>Choose a view</label>
       <choice value="table">Table</choice>
       <choice value="chart">Chart</choice>
         <condition value="table">
           <set token="showTable">true</set>
           <unset token="showChart"></unset>
         <condition value="chart">
           <set token="showChart">true</set>
           <unset token="showTable"></unset>
0 Karma


Unforunately, there is no straightforward way to do what you want in SimpleXML. This is largely an issue because you cannot use the change element of the form inputs on the default token model (see my post here: https://answers.splunk.com/answers/548647/enhancement-request-make-change-conditional-tokens.html)

There is a work-around you can do to accomplish what you want. It requires using a hidden search in the XML to set a token whenever the submit occurs.

First, add a hidden search in your XML. You can put the search just before the fieldset element. What this search does is set a custom token search_start whenever both of your tokens are set and the submit button is clicked. Note, you need to use your specific token names. I assumed a token name for the region to just be region so update accordingly. Also, I assumed your timepicker does has a token name of time. Update this example reflect to your custom name if different.

  <query>| gentimes start=-1 | eval token1 = $region|s$</query>
    <set token="search_start">true</set>

Now, you need to add a change handler to both the timepicker and the region inputs. The code is the same for both. It should look like this. Just copy and paste that into the definition of both input elements. This will reset the searh_start token any time either input is changed.

  <unset token="search_start"/>

Lastly, use depends="$search_start$" on the panel elements you want to hide until the submit button is clicked.

0 Karma

New Member

this is in place for region and timerange tokens..

fieldset submitButton="true" autoRun="false"
input type="time" token="timerange" searchWhenChanged="false"
input type="Reg" token="region" searchWhenChanged="false"
can i set token for submit?

0 Karma


No, you cannot. You have to do some kind of workaround like I posted (e.g., the intermediary search) or write custom JavaScript.

0 Karma


@emraghuram, kindly post XML using Code Button (i.e. 101010) or else charactes migh get escaped. You code is looking like plain text instead of XML.

| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Super Champion

try adding this to your timerange and region tokens searchWhenChanged="false"

ie: <input type="time" token="timerange" searchWhenChanged="false">

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!