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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...