Dashboards & Visualizations

How to make multiple panels to disappear/appear when changes to radio button happen?

thisemailwillbe
Explorer

So basically what I'm trying to do it that I want a radio button at the top of the page and depending on one of the four choices of sais radio button, make a whole swath of panels to appear/disappear. I'm having troubles trying to figure out how to use the tokens to achieve this. Thanks in advance for any help! (I should also mention that I'm running 7.2.5)

0 Karma
1 Solution

manjunathmeti
Champion

hi @thisemailwillbeusedfortesting,

Try this:

<form hideSplunkBar="true">
  <label>Choose filters</label>
  <fieldset submitButton="false">
    <input type="radio" token="checkbox">
      <label>Checkbox</label>
      <choice value="checkbox1">Show Panel 1</choice>
      <choice value="checkbox2">Show Panel 2</choice>
      <choice value="checkbox3">Show Panel 3</choice>
      <choice value="checkbox4">Show Panel 4</choice>
      <change>
        <condition value="checkbox1">
          <set token="flag1">true</set>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox2">
          <set token="flag2">true</set>
          <unset token="flag1"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox3">
          <set token="flag3">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox4">
          <set token="flag4">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$flag1$">
      <title>Panel 1</title>
      <table>
        <title>Count by sourcetype</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by sourcetype</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag2$">
      <title>Panel 2</title>
      <table>
        <title>Count by source</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by source</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag3$">
      <title>Panel 3</title>
      <table>
        <title>Count by host</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by host</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag4$">
      <title>Panel 4</title>
      <table>
        <title>Count by splunk server</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by splunk_server</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

View solution in original post

manjunathmeti
Champion

hi @thisemailwillbeusedfortesting,

Try this:

<form hideSplunkBar="true">
  <label>Choose filters</label>
  <fieldset submitButton="false">
    <input type="radio" token="checkbox">
      <label>Checkbox</label>
      <choice value="checkbox1">Show Panel 1</choice>
      <choice value="checkbox2">Show Panel 2</choice>
      <choice value="checkbox3">Show Panel 3</choice>
      <choice value="checkbox4">Show Panel 4</choice>
      <change>
        <condition value="checkbox1">
          <set token="flag1">true</set>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox2">
          <set token="flag2">true</set>
          <unset token="flag1"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox3">
          <set token="flag3">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox4">
          <set token="flag4">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$flag1$">
      <title>Panel 1</title>
      <table>
        <title>Count by sourcetype</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by sourcetype</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag2$">
      <title>Panel 2</title>
      <table>
        <title>Count by source</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by source</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag3$">
      <title>Panel 3</title>
      <table>
        <title>Count by host</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by host</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag4$">
      <title>Panel 4</title>
      <table>
        <title>Count by splunk server</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by splunk_server</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

thisemailwillbe
Explorer

Thank you! This is exactly what I needed. Cheers!

0 Karma

manjunathmeti
Champion

You're welcome 🙂

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!

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

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...