Dashboards & Visualizations

Multiselect default to all?

jrs42
Path Finder

I'm trying to create what is effectively a "server" dropdown in a dashboard, where I want to allow people to filter on one or more servers from a lookup.  By default, I want the visualization to show for all servers.  I have the lookup pulling values, but I'm stuck trying to figure out how to make it so that they don't have to unselect a default "*" value.  Ideally, the input is empty by default (or it can show some value like "*" or "all") but once they start selecting individual servers that "all" option is removed.  Conversely, if they remove all servers from the filter, it should once again act like "*".

Here's a stripped-down version of what I'm trying to do:

 

 

<form version="1.1" theme="dark">
  <label>My dashboard</label>
  <fieldset submitButton="false">
    <input type="time" token="field1">
      <label></label>
      <default>
        <earliest>-5m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="multiselect" token="server" searchWhenChanged="true">
      <label>server</label>
      <search>
        <query>| inputlookup server_lookup.csv</query>
      </search>
      <fieldForLabel>server</fieldForLabel>
      <fieldForValue>server</fieldForValue>
      <delimiter>, </delimiter>
      <default>*</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Some panel</title>
      <chart>
        <search>
          <query>index=* server_used IN ($server$)
| stats median(some_value)</query>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
          <sampleRatio>1</sampleRatio>
          <refresh>1m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
        <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
        <option name="charting.axisTitleX.visibility">visible</option>
        <option name="charting.axisTitleY.visibility">visible</option>
        <option name="charting.axisTitleY2.visibility">visible</option>
        <option name="charting.axisX.abbreviation">none</option>
        <option name="charting.axisX.scale">linear</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.axisY2.abbreviation">none</option>
        <option name="charting.axisY2.enabled">0</option>
        <option name="charting.axisY2.scale">inherit</option>
        <option name="charting.chart">radialGauge</option>
        <option name="charting.chart.bubbleMaximumSize">50</option>
        <option name="charting.chart.bubbleMinimumSize">10</option>
        <option name="charting.chart.bubbleSizeBy">area</option>
        <option name="charting.chart.nullValueMode">gaps</option>
        <option name="charting.chart.rangeValues">[0,10,30,100]</option>
        <option name="charting.chart.showDataLabels">none</option>
        <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.chart.style">shiny</option>
        <option name="charting.gaugeColors">["0x118832","0xcba700","0xd41f1f"]</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.layout.splitSeries.allowIndependentYRanges">0</option>
        <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.legend.mode">standard</option>
        <option name="charting.legend.placement">right</option>
        <option name="charting.lineWidth">2</option>
        <option name="refresh.display">progressbar</option>
        <option name="trellis.enabled">0</option>
        <option name="trellis.scales.shared">1</option>
        <option name="trellis.size">medium</option>
      </chart>
    </panel>
  </row>
</form>

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this - note that the case function has to all be on one line for it to parse correctly

<form version="1.1" theme="dark">
  <label>My dashboard</label>
  <fieldset submitButton="false">
    <input type="time" token="field1">
      <label></label>
      <default>
        <earliest>-5m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="multiselect" token="server" searchWhenChanged="true">
      <label>server</label>
  	  <choice value="All">All</choice>
      <search>
        <query>| inputlookup server_lookup.csv</query>
      </search>
      <fieldForLabel>server</fieldForLabel>
      <fieldForValue>server</fieldForValue>
	  <prefix>(</prefix>
	  <valuePrefix>server_used ="</valuePrefix>
	  <valueSuffix>"</valueSuffix>
      <delimiter> OR </delimiter>
	  <suffix>)</suffix>
      <default>All</default>
	  <change>
	    <eval token="form.server">case(mvcount('form.server')=0,"All",mvcount('form.server')&gt;1 AND mvfind('form.server',"All")&gt;0,"All",mvcount('form.server')&gt;1 AND mvfind('form.server',"All")=0,mvfilter('form.server'!="All"),1==1,'form.server')</eval>
	    <eval token="server_choice">if(mvfind('form.server',"All")=0,"server_used=*",$server$)</eval>
	  </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Some panel</title>
      <chart>
        <search>
          <query>index=* $server_choice$
| stats median(some_value)</query>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
          <sampleRatio>1</sampleRatio>
          <refresh>1m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
        <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
        <option name="charting.axisTitleX.visibility">visible</option>
        <option name="charting.axisTitleY.visibility">visible</option>
        <option name="charting.axisTitleY2.visibility">visible</option>
        <option name="charting.axisX.abbreviation">none</option>
        <option name="charting.axisX.scale">linear</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.axisY2.abbreviation">none</option>
        <option name="charting.axisY2.enabled">0</option>
        <option name="charting.axisY2.scale">inherit</option>
        <option name="charting.chart">radialGauge</option>
        <option name="charting.chart.bubbleMaximumSize">50</option>
        <option name="charting.chart.bubbleMinimumSize">10</option>
        <option name="charting.chart.bubbleSizeBy">area</option>
        <option name="charting.chart.nullValueMode">gaps</option>
        <option name="charting.chart.rangeValues">[0,10,30,100]</option>
        <option name="charting.chart.showDataLabels">none</option>
        <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.chart.style">shiny</option>
        <option name="charting.gaugeColors">["0x118832","0xcba700","0xd41f1f"]</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.layout.splitSeries.allowIndependentYRanges">0</option>
        <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.legend.mode">standard</option>
        <option name="charting.legend.placement">right</option>
        <option name="charting.lineWidth">2</option>
        <option name="refresh.display">progressbar</option>
        <option name="trellis.enabled">0</option>
        <option name="trellis.scales.shared">1</option>
        <option name="trellis.size">medium</option>
      </chart>
    </panel>
  </row>
</form>

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this - note that the case function has to all be on one line for it to parse correctly

<form version="1.1" theme="dark">
  <label>My dashboard</label>
  <fieldset submitButton="false">
    <input type="time" token="field1">
      <label></label>
      <default>
        <earliest>-5m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="multiselect" token="server" searchWhenChanged="true">
      <label>server</label>
  	  <choice value="All">All</choice>
      <search>
        <query>| inputlookup server_lookup.csv</query>
      </search>
      <fieldForLabel>server</fieldForLabel>
      <fieldForValue>server</fieldForValue>
	  <prefix>(</prefix>
	  <valuePrefix>server_used ="</valuePrefix>
	  <valueSuffix>"</valueSuffix>
      <delimiter> OR </delimiter>
	  <suffix>)</suffix>
      <default>All</default>
	  <change>
	    <eval token="form.server">case(mvcount('form.server')=0,"All",mvcount('form.server')&gt;1 AND mvfind('form.server',"All")&gt;0,"All",mvcount('form.server')&gt;1 AND mvfind('form.server',"All")=0,mvfilter('form.server'!="All"),1==1,'form.server')</eval>
	    <eval token="server_choice">if(mvfind('form.server',"All")=0,"server_used=*",$server$)</eval>
	  </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Some panel</title>
      <chart>
        <search>
          <query>index=* $server_choice$
| stats median(some_value)</query>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
          <sampleRatio>1</sampleRatio>
          <refresh>1m</refresh>
          <refreshType>delay</refreshType>
        </search>
        <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
        <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
        <option name="charting.axisTitleX.visibility">visible</option>
        <option name="charting.axisTitleY.visibility">visible</option>
        <option name="charting.axisTitleY2.visibility">visible</option>
        <option name="charting.axisX.abbreviation">none</option>
        <option name="charting.axisX.scale">linear</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.axisY2.abbreviation">none</option>
        <option name="charting.axisY2.enabled">0</option>
        <option name="charting.axisY2.scale">inherit</option>
        <option name="charting.chart">radialGauge</option>
        <option name="charting.chart.bubbleMaximumSize">50</option>
        <option name="charting.chart.bubbleMinimumSize">10</option>
        <option name="charting.chart.bubbleSizeBy">area</option>
        <option name="charting.chart.nullValueMode">gaps</option>
        <option name="charting.chart.rangeValues">[0,10,30,100]</option>
        <option name="charting.chart.showDataLabels">none</option>
        <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.chart.style">shiny</option>
        <option name="charting.gaugeColors">["0x118832","0xcba700","0xd41f1f"]</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.layout.splitSeries.allowIndependentYRanges">0</option>
        <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.legend.mode">standard</option>
        <option name="charting.legend.placement">right</option>
        <option name="charting.lineWidth">2</option>
        <option name="refresh.display">progressbar</option>
        <option name="trellis.enabled">0</option>
        <option name="trellis.scales.shared">1</option>
        <option name="trellis.size">medium</option>
      </chart>
    </panel>
  </row>
</form>
0 Karma

jrs42
Path Finder

Edit: I'm working through this, still.  Obviously, I changed what I'm working on to post here so I didn't share anything inappropriate, so I may be running into translation issues :). 

Got it working as desired.  I changed the query to perform an IN instead of a collection of ORs, like so:

 

<prefix>server_used IN (</prefix>
<suffix>)</suffix>
<delimiter>, </delimiter>

 

but otherwise it's pretty much what you posted.  TY!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...