Dashboards & Visualizations

How to produce a dynamic number of panels in a dashboard based on a form input?

splunk403
Explorer

Need a sample code to produce a dynamic number of panels in a dashboard based on a form input. Anybody successful in achieving it?

Thanks

0 Karma

MuS
SplunkTrust
SplunkTrust

HI splunk403,

there is a way you can selectively show or hide panels based on the drop down selection.
Take this run everywhere dashboard to see how the panels change based on the drop down section:

<form>
  <label>Show panels dynamically based on drop down selection</label>
  <description>https://answers.splunk.com/answers/513020/how-to-produce-a-dynamic-number-of-panels-in-a-das-2.html</description>
  <search id="internal_data">
    <query>index=_internal earliest=-1h@h latest=now | table _time, source, sourcetype, host</query>
  </search>
  <fieldset submitButton="false">
    <input type="dropdown" token="category" searchWhenChanged="true">
      <label>select panel to show:</label>
      <choice value="1">Panel1</choice>
      <choice value="2">Panel2</choice>
      <choice value="3">Panel3</choice>
      <default>1</default>
      <change>
        <condition value="1">
          <unset token="panel2"></unset>
          <unset token="panel3"></unset>
          <set token="panel1"></set>
        </condition>
        <condition value="2">
          <unset token="panel1"></unset>
          <unset token="panel3"></unset>
          <set token="panel2"></set>
        </condition>
        <condition value="3">
          <unset token="panel1"></unset>
          <unset token="panel2"></unset>
          <set token="panel3"></set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row depends="$panel1$">
    <panel>
      <title>Panel 1</title>
      <chart>
        <search base="internal_data">
          <query>|stats count by host</query>
        </search>
        <option name="charting.chart">column</option>
      </chart>
    </panel>
  </row>
  <row depends="$panel2$">
    <panel>
      <title>Panel 2</title>
      <chart>
        <search base="internal_data">
          <query>|stats count by source</query>
        </search>
        <option name="charting.chart">column</option>
      </chart>
    </panel>
  </row>
  <row depends="$panel3$">
    <panel>
      <title>Panel 3</title>
      <chart>
        <search base="internal_data">
          <query>|stats count by sourcetype</query>
        </search>
        <option name="charting.chart">pie</option>
      </chart>
      <chart>
        <search base="internal_data">
          <query>|stats count by host</query>
        </search>
        <option name="charting.chart">column</option>
      </chart>
    </panel>
  </row>
</form>

Hope this helps ...

cheers, MuS

adonio
Ultra Champion

MuS thanks! I learned something new today 🙂

0 Karma

splunk403
Explorer

Thanks MuS .This help when the number panels are predefined .

Any clue for dynamics number of panels .

0 Karma

MuS
SplunkTrust
SplunkTrust

For SimpleXML it is predefined, but I'm sure you can do it as you mentioned using the web framework.

My two cents: I would simply use a table panel (maybe with some overlay and spark line?) to show the two metrics for the various numbers of servers.

0 Karma

splunk403
Explorer

Any clue how to do it ?

0 Karma

adonio
Ultra Champion

Can you elaborate on the use case? what exactly are you trying to achieve?
I dont think the feature you are asking for exists.

0 Karma

splunk403
Explorer

For a server i am creating two panels for two of its resouces .Now the requirement is when i select Frame(group of servers) it has to display the two panels for each of the server .

Number of servers in a frame will be dyanmic ,so when I select a frame the number of display panels will be different .

Hope this helps .

Thanks

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...