Dashboards & Visualizations

Set Token Not working when values in Drop down is changed in Dashboard

Chiddarthan
New Member

First time when dashboard is loading change condition is detected and correct part is replaced in Web Request Panel. When i change the value in drop down, Change condition is not getting recognized and query in panel is like below

"cart | timechart count"

 

<form>
   <label>Test</label>
   <fieldset submitButton="false" autoRun="true">
      <input type="time" token="timePicker">
         <label />
         <default>
            <earliest>-4h@m</earliest>
            <latest>now</latest>
         </default>
      </input>
      <input type="dropdown" token="serviceName">
         <label>Service</label>
         <choice value="">Select a Service</choice>
         <choice value="lpd">LPD</choice>
         <choice value="cart">Cart</choice>
         <choice value="identity">Identity</choice>
         <default>Select a Service</default>
         <initialValue>Select a Service</initialValue>
         <change>
            <condition value="lpd">
               <set token="serviceName">index=test1</set>
            </condition>
            <condition value="cart">
               <set token="serviceName">index=test2</set>
            </condition>
            <condition value="identity">
               <set token="serviceName">index=test3</set>
            </condition>
         </change>
      </input>
      <input type="radio" token="byHost" searchWhenChanged="true">
         <label>By Host</label>
         <choice value="by host">Yes</choice>
         <choice value="">No</choice>
         <default>by host</default>
         <initialValue>by host</initialValue>
      </input>
   </fieldset>
   <row>
      <panel>
         <title>Web Request</title>
         <chart>
            <search>
               <query>$serviceName$ | timechart count</query>
               <earliest>$timePicker.earliest$</earliest>
               <latest>$timePicker.latest$</latest>
            </search>
            <option name="charting.chart">line</option>
         </chart>
      </panel>
   </row>
</form>

 

Labels (2)
0 Karma

dmarling
Builder

You have token contention for the serviceName token which is what is causing your issue.  You are using change to set the token that you are also using as the token for the drop down selector.  You need to make a choice on how you want the token to be populated, either have the drop down selections populate serviceName or the change event on the input.  The quickest fix is to just assign a different token to the drop down selector:

<form>
  <label>Test</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="time" token="timePicker">
      <label></label>
      <default>
        <earliest>-4h@m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="serviceNamedropdown">
      <label>Service</label>
      <choice value="">Select a Service</choice>
      <choice value="lpd">LPD</choice>
      <choice value="cart">Cart</choice>
      <choice value="identity">Identity</choice>
      <default>Select a Service</default>
      <initialValue>Select a Service</initialValue>
      <change>
        <condition value="lpd">
          <set token="serviceName">index=test1</set>
        </condition>
        <condition value="cart">
          <set token="serviceName">index=test2</set>
        </condition>
        <condition value="identity">
          <set token="serviceName">index=test3</set>
        </condition>
      </change>
    </input>
    <input type="radio" token="byHost" searchWhenChanged="true">
      <label>By Host</label>
      <choice value="by host">Yes</choice>
      <choice value="">No</choice>
      <default>by host</default>
      <initialValue>by host</initialValue>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Web Request</title>
      <chart>
        <search>
          <query>$serviceName$ | timechart count</query>
          <earliest>$timePicker.earliest$</earliest>
          <latest>$timePicker.latest$</latest>
        </search>
        <option name="charting.chart">line</option>
      </chart>
    </panel>
  </row>
</form>
If this comment/answer was helpful, please up vote it. Thank you.
0 Karma

niketn
Legend

@Chiddarthan you would also need to enable searchWhenChanged="true" for the dropdown

<input type="dropdown" token="serviceNamedropdown" searchWhenChanged="true">


Rest all code remains the same as you originally posted.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...