Dashboards & Visualizations

Multiselect option not getting displayed if the option is chosen in differnt order

sangs8788
Communicator

Hi,

I have a dashboard with multiselect input,

<fieldset submitButton="false" autoRun="true">
    <input type="multiselect" token="metric" searchWhenChanged="true">
      <label>Metric</label>
      <choice value="show_latency">Latency</choice>
      <choice value="show_throughput">Throughput</choice>
      <choice value="show_error">Error</choice>
      <choice value="*">All</choice>
      <delimiter> </delimiter>
       <change>
      <condition label="Latency">
        <set token="show_latency">true</set>
        <unset token="show_throughput"></unset>
        <unset token="show_error"></unset>
      </condition>
      <condition label="Throughput">
        <unset token="show_latency"></unset>
        <set token="show_throughput">true</set>
        <unset token="show_error"></unset>
      </condition>
      <condition label="Error">
        <unset token="show_latency"></unset>
        <unset token="show_throughput"></unset>
        <set token="show_error">true</set>
      </condition>
      <condition label="All">
        <set token="show_latency">true</set>
        <set token="show_throughput">true</set>
        <set token="show_error">true</set>
      </condition>
      <condition match="isnull(value)">
        <unset token="latency"></unset>
        <unset token="throughput"></unset>
        <unset token="error"></unset>
      </condition>
    </change>
    </input>
  </fieldset>

  <row>
    <panel depends="$show_latency$">
    </panel>
    <panel depends="$show_latency$">
   </panel>
</row>
 <row>
    <panel depends="$show_throughput$">
    </panel>
    <panel depends="$show_throughput$">
   </panel>
</row>

The probelm here is if i select Latency first, the panels of Latency gets selected. If I select Throughput first and Latency - second , Latency doesnt get displayed.

Could someone please help me out here

Tags (1)
0 Karma

niketn
Legend

@sangs8788 the <change> Event Handler for Check Box and Multi Select input works only if single value is selected not multiple. The same has been called out in Documentation and here on Splunk Answers. Refer to documentation: https://docs.splunk.com/Documentation/Splunk/latest/Viz/EventHandlerReference#Event_handler_element

So you have two options

1) Use independent search to take selected values from multi select input and generate tokens using Search Event Handler instead as per your needs: https://answers.splunk.com/answers/641411/hidedisplay-panels-using-multiselect.html

2) Use Simple XML JavaScript Extension and SplunkJS Stack to code the selected value as per your need and set tokens.https://answers.splunk.com/answers/504338/using-eventhandler-with-multiselectinput.html

Following is a run anywhere example based on your use case with the help of independent search:

alt text

Following is Simple XML run anywhere example:

<form>
  <label>Multiselect option</label>

  <fieldset submitButton="false" autoRun="true">
    <input type="multiselect" token="metric" searchWhenChanged="true">
      <label>Metric</label>
      <choice value="show_latency">Latency</choice>
      <choice value="show_throughput">Throughput</choice>
      <choice value="show_error">Error</choice>
      <choice value="show_all">All</choice>
      <delimiter> </delimiter>
    </input>
  </fieldset>
    <search>
    <query>| makeresults
| fields - _time 
| eval seletedValues=split("$metric$","\s")
| eval show_latency=case(match("$metric$","show_latency"),"true")
| eval show_throughput=case(match("$metric$","show_throughput"),"true")
| eval show_error=case(match("$metric$","show_error"),"true")
| eval show_all=case(match("$metric$","show_all") OR (match("$metric$","show_latency") AND match("$metric$","show_throughput") AND match("$metric$","show_error")),"true")
    </query>
    <done>
      <condition match="$result.show_all$==&quot;true&quot;">
        <set token="show_throughput">true</set>
        <set token="show_latency">true</set>
        <set token="show_error">true</set>
      </condition>
      <condition match="$result.show_throughput$==&quot;true&quot; AND $result.show_latency$==&quot;true&quot;">
        <set token="show_throughput">true</set>
        <set token="show_latency">true</set>
        <unset token="show_error"></unset>
      </condition>
      <condition match="$result.show_throughput$==&quot;true&quot; AND $result.show_error$==&quot;true&quot;">
        <set token="show_throughput">true</set>
        <unset token="show_latency"></unset>
        <set token="show_error">true</set>
      </condition>
      <condition match="$result.show_latency$==&quot;true&quot; AND $result.show_error$==&quot;true&quot;">
        <unset token="show_throughput"></unset>
        <set token="show_latency">true</set>
        <set token="show_error">true</set>
      </condition>
      <condition match="$result.show_throughput$==&quot;true&quot;">
        <set token="show_throughput">true</set>
        <unset token="show_latency"></unset>
        <unset token="show_error"></unset>
      </condition>
      <condition match="$result.show_latency$==&quot;true&quot;">
        <unset token="show_throughput"></unset>
        <set token="show_latency">true</set>
        <unset token="show_error"></unset>
      </condition>
      <condition match="$result.show_error$==&quot;true&quot;">
        <unset token="show_throughput"></unset>
        <unset token="show_latency">true</unset>
        <set token="show_error">true</set>
      </condition>
    </done>
  </search>
   <row>
     <panel depends="$show_latency$">
       <html>
         <div>Latency Panel</div>
       </html>
     </panel>
     <panel depends="$show_throughput$">
       <html>
         <div>Throughput Panel</div>
       </html>       
     </panel>
     <panel depends="$show_error$">
       <html>
         <div>Error Panel</div>
       </html>
    </panel>
 </row>
</form>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

renjith_nair
Legend

@sangs8788,
Are you trying to use both Latency & Throughput at the same time in the multiselect? If you are selecting both at the same time, both will cancel each other due to the token set/unset and we might see unexpected results.

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