Dashboards & Visualizations

How to hide and show number of panels based on dynamic dropdown values?

kavyamohan
Explorer

I have a dynamic dropdown which shows values(the number of values will keep on changing in future). We have some panels (the number of panels also will keep on changing according to requirement). We have only token for ex,field1 for dynamic dropdown. The panels should hide and show based on the value selected in the dynamic dropdown. For ex., if i have 10 panels only 5 panels will be dependant on "test1" where "test1" is the value selected in the dropdown . So in this case i will be giving only dropdown token i.e "field1" for all the 10 panels,but how should i make the 5 panels display only when i select "test1" and other panels will be hidden. . So in this line what should be written inside the dollar symbol to make the panels display dynamically. Note: I don't need any js or css and i need only dynamic query. i have searched multiple links where none of that suits my scenario.

Labels (1)
0 Karma

chinmoya
Communicator

Check the below dashboard code. It should help you out...

Code for dropdown

<input type="dropdown" token="choice" searchWhenChanged="true">
  <label>Choice</label>
  <choice value="test1">test1</choice>
  <choice value="test2">test2</choice>
  <change>
    <condition value="test1">
      <set token="panel1"></set>
      <unset token="panel2"></unset>
    </condition>
    <condition value="test2">
       <unset token="panel1"></unset>
      <set token="panel2"></set>
    </condition>
  </change>
  <selectFirstChoice>true</selectFirstChoice>
</input>

Code for panel

<panel depends="$panel1$">
  <table>
    <title>Panel1</title>
    <search>
      <query>| makeresults | eval panel1 = "Panel1"</query>
      <earliest>-24h@h</earliest>
      <latest>now</latest>
    </search>
    <option name="drilldown">none</option>
  </table>
</panel>
<panel depends="$panel2$">
  <table>
    <title>Panel2</title>
    <search>
      <query>| makeresults | eval panel2 = "Panel2"</query>
      <earliest>-24h@h</earliest>
      <latest>now</latest>
    </search>
    <option name="drilldown">none</option>
  </table>
</panel>
0 Karma

kavyamohan
Explorer

Thanks for your quick reply. First it is dynamic dropdown, So choice values won't come. Values will differ also. I don't want unset/set(it should be dynamic as i mentioned in the question). We have tried this also, it won't suit for our requirement.

0 Karma

chinmoya
Communicator

So if your dropdown is dynamic. On what criteria are your panels dependent.
Like on which kind of selection do you want which panel to be shown.

Say down the line you get test5 as an input in the dropdown, then which panel should be visible.

0 Karma

kavyamohan
Explorer

I have created 5 panels which i know it should come on selecting "test5" as input from dropdown but how do i give it dynamic to those panels. The search query is different for all the panels and dependant on the input from dropdown. Do you have any idea?

0 Karma

vidhi_159
Observer

@kavyamohan did you get answer or were able to implement this? I have similar requirement and need some guidance. 

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...