Dashboards & Visualizations

How to hide panels, based on other panel's result?

akarivaratharaj
Communicator

I have three panels in my dashboard.
Panel1 & Panel2 —> have some query and fetch me some result.
Panel3 —> just have custom text which displays whenever the Panel1 & Panel2 do not have any results.

Requirements:
1. Hide Panel1 & Panel2 when job result is 0. Show the Panel 3
2. Hide Panel 3 when job result is !=0. Show the Panel & Panel2

I have used the below code to hide the Panel1 & Panel2 when there are no results

<progress>
            <condition match="$job.resultCount$ == 0">
              <unset token="hide_panel2"></unset>
            </condition>
            <condition>
              <set token="hide_panel2">true</set>
            </condition>
          </progress>

There is no issue with this. Its working fine.

But my Panel3 has to be hidden whenever the Panel1 & Panel2 are visible. As like above code, I have tried the similar set of code to hide Panel3 based on Panel1 & Panel2 values

<progress>
            <condition match="$result.Usage_Count$ != 0">
              <unset token="hide_panel3"></unset>
            </condition>
            <condition>
              <set token="hide_panel3">true</set>
            </condition>
          </progress>

But still the panel3 is visible in all kind of conditions. I am not knowing where I am making the mistake. Could anyone please help me.

Labels (3)
0 Karma
1 Solution

vnravikumar
Champion

Hi

Try this

<dashboard>
  <label>panel</label>
  <row>

    <panel rejects="$hide_panel$">
      <table>
        <title>Panel1</title>
        <search>
          <query>index="_internal" |stats count by host </query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <progress>
            <condition match="$job.resultCount$ == 0">
              <set token="hide_panel">true</set>
            </condition>
            <condition>
               <unset token="hide_panel"></unset>

            </condition>
          </progress>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel rejects="$hide_panel$">
      <table>
        <title>Panel2</title>
        <search>
          <query>index="_internal" |stats count by host  |stats count by host </query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <progress>
             <condition match="$job.resultCount$ == 0">
              <set token="hide_panel">true</set>
            </condition>
            <condition>
               <unset token="hide_panel"></unset>

            </condition>
          </progress>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
  <row>
    <panel depends="$hide_panel$">
      <table>
        <title>Panel3</title>
        <search>
          <query>index="_internal" |stats count by host</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</dashboard>

View solution in original post

vnravikumar
Champion

Hi

Try this

<dashboard>
  <label>panel</label>
  <row>

    <panel rejects="$hide_panel$">
      <table>
        <title>Panel1</title>
        <search>
          <query>index="_internal" |stats count by host </query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <progress>
            <condition match="$job.resultCount$ == 0">
              <set token="hide_panel">true</set>
            </condition>
            <condition>
               <unset token="hide_panel"></unset>

            </condition>
          </progress>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel rejects="$hide_panel$">
      <table>
        <title>Panel2</title>
        <search>
          <query>index="_internal" |stats count by host  |stats count by host </query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <progress>
             <condition match="$job.resultCount$ == 0">
              <set token="hide_panel">true</set>
            </condition>
            <condition>
               <unset token="hide_panel"></unset>

            </condition>
          </progress>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
  <row>
    <panel depends="$hide_panel$">
      <table>
        <title>Panel3</title>
        <search>
          <query>index="_internal" |stats count by host</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</dashboard>

akarivaratharaj
Communicator

@vnravikumar I have one more problem.
I have a multiselect input (token is App_Value). So whenever I click all option (all=*), only then my panel1 should display. For any other inputs, my panel1 should be hidden.
Currently I am trying like this but not working

<done>
<condition $App_Value$="*">
<set token="hide_panel">true</set>
</condition>
<condition>
<unset token="hide_panel"></unset>
</condition>
</done>

Can you please help me

0 Karma

vnravikumar
Champion

HI, this is for the different requirement or for the same one.

0 Karma

akarivaratharaj
Communicator

This is for the same dashboard. Earlier I had three panels, now I have added two more.
Panel1 & Panel2—> Shows overall results only when the input selected as All. Which is token App_Value =*
Panel3 & Panel4 -> have some query and fetch me some result.
Panel5 —> just have custom text which displays whenever the Panel1, Panel2, Panel3 & Panel4 do not have any results.

I have tried the below conditions to hide the panels accordingly
<condition match="$App_Value$ == *">
<condition $App_Value$="*">

But both of these are not working. Panel 1 & Panel 2 are displaying whenever Panel 3 & Panel4 also are displaying.
Could you please help me.

0 Karma

vnravikumar
Champion

Hi, check this sample

<form>
  <label>panelsample</label>
  <fieldset submitButton="false">
    <input type="multiselect" token="field1" searchWhenChanged="true">
      <label>field1</label>
      <choice value="*">All</choice>
      <choice value="one">One</choice>
      <change>
        <condition match="field1 == &quot;*&quot;">
          <set token="showPanel">true</set>
        </condition>
         <condition>
          <unset token="showPanel"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row depends="$showPanel$">
    <panel>
      <table>
        <search>
          <query>index="_internal" |stats count by host</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
  <row depends="$showPanel$">
    <panel>
      <table>
        <search>
          <query>index="_internal" |stats count by host</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>
0 Karma

akarivaratharaj
Communicator

@vnravikumar , I have tried your above sample code with two situations.

Situation 1 -> This is working fine only when I have two values in my input (as you mentioned All & one).
Situation 2 -> When I have multiple values in my input, delimiter comes into picture as this is a multi select input. So during that time, my Panel1 and Panel2 are not at all displaying for any kind of values I select. Though I am selecting All values option, these panels are still hidden

I tried using the rejects command in other dashboards also. But this does not work

0 Karma

vnravikumar
Champion

in your multiselect if you choose all whether other items are getting removed. similarly if you choose one item whether all gets removed?

0 Karma

akarivaratharaj
Communicator

No. If I choose All, still other input values are showing for selection. Similarly if I choose any other items also, the other item values are showing.

0 Karma

vnravikumar
Champion

once you implement I guess your problem will get resolve

0 Karma

akarivaratharaj
Communicator

@vnravikumar I referred the link which you shared. People have suggested both Java script and xml code also. But our requirement does not match with this, as they are suggesting to disappear other items when one item selected.
If that is the case, we no need to prefer multiselect, just we can go with drop down list.
I have checked the splunk docs and got the answer.
There is a little change in the code which you suggested me.

<change>
        <condition label="All Apps">
          <set token="showPanel">true</set>
        </condition>
        <condition>
          <unset token="showPanel"></unset>
        </condition>
      </change>

This I added in my multiselect input code block. Then it worked.

0 Karma

hrs2019
Path Finder

HI @vnravikumar how i can hide the panel if it is showing Search is waiting for input...

i am using this condition

    <set token="display_count">true</set>
  </condition>
  <condition>
    <unset token="display_count"></unset>
  </condition>
0 Karma

niketn
Legend

@hrs2019 In the example in the answer above depends has been added to the row. depends can be added to <row>, <panel>, <viz> and even <search> to control the behavior depending on whether the token is set or not. Just add depends with the token which is needs to be set for the search to run.

For examples:

<panel depends="$mytoken$">
    <table>
         <search>
              <query>| makeresults
             | fields - _time
             | eval temp="$mytoken$"
              </query>
         </search>
    <table>
</panel>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

hrs2019
Path Finder

@niketnilay Yaah got it thanks again,
just one more help i need if we have 0 out put for any panel in given time i just want to use a message like "data is not available"
panel 1 panle 2 panel 3
0 0 0
my requirement
panel 1 panle 2 panel 3
data is not available" data is not available" data is not available"

0 Karma

niketn
Legend

@hrs2019, refer to the following question, where my answers has an option with depends and rejects, based on $job.resultCount$ (which basically tells whether search returned results or not) to toggle between your actual data panel vs. your custom panel/message.
The same is also described in Splunk Documentation and Splunk Dashboard Examples App. Please go through them to grasp the concepts.

https://answers.splunk.com/answers/582253/replacing-no-results-found-with-0.html

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

hrs2019
Path Finder

@niketnilay Thanks for your all help.

0 Karma

niketn
Legend

@hrs2019 Glad it worked. Do up vote the comments/answers that helped!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

vnravikumar
Champion

can you please reiterate the requirement once.

0 Karma

akarivaratharaj
Communicator

@vnravikumar Wow!! Its working...!! Thankyou for the quick response

0 Karma

akarivaratharaj
Communicator

Hi @vnravikumar,

I am facing one more problem with the above code. If I provide the shorter time duration like 15 minutes, 1 hour, 4 hours, my query is running faster, fetching the results and showing Panel1 & Panel2 . If there are no results, it is giving me the Panel3.

But, whenever we give larger time duration (which fetches more logs/events) like 24 hours, 3 days, 1 week, etc., my query is taking sometime to execute and show the results. In between this query search/execute time, my panel3 is getting displayed. Once the query execution is over and it gives me result, my panel3 disappears and panel1 & panel2 is getting displayed.

That should not happen. Basically my panel1 & panel2 is executing its query, nothing should be displayed on the dashboard. Once the query completes its execution it should display either case1 or case2.

Could you please help me on this?

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

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