<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hide a panel when the results of a search return in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326611#M21136</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm sure I am missing something simple, but thought I should ask. I am running a search that does the following:&lt;/P&gt;

&lt;P&gt;Fields&lt;BR /&gt;
- dv_node = The string that holds the hostname of devices&lt;BR /&gt;
- dv_number = A unique alert ID #&lt;BR /&gt;
- state = a value of "Processed" when opened and a value of "Closed" when closed&lt;BR /&gt;
- dv_severity = Clear means the alert has closed&lt;/P&gt;

&lt;P&gt;The first part of the search grabs the alerts that are active. The second part of the search grabs the alerts that are closed. If it finds a match between the dv_number of an ACTIVE alert in the 1st search &amp;amp; the dv_number of a CLOSED alert in the 2nd search, eliminate that dv_number from the final count. This is because the logs we process may have many entries along the way, but there should be at LEAST 1 ACTIVE entry and 1 CLOSED entry in the logs (Since, if something alarms, it has to eventually clear right?).&lt;/P&gt;

&lt;P&gt;At this point, the only thing that should be showing up are active items. At this point, we run a dedup to eliminate those "many entries along the way" log. Basically, lets ignore everything that came after that initial alert, until a matching closed event is found. &lt;/P&gt;

&lt;P&gt;Finally, do a count by dv_node to get a # of active entries per hostname.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;panel&amp;gt;
  &amp;lt;title&amp;gt;Active Events (Last 5 minutes)&amp;lt;/title&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;[search dv_severity NOT "Clear" state=Processed | fields dv_number ] NOT [search dv_severity="Clear" state=Closed | fields dv_number ]  | dedup dv_number | stats count by dv_node&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;-5m&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
      &amp;lt;refresh&amp;gt;2m&amp;lt;/refresh&amp;gt;
      &amp;lt;refreshType&amp;gt;delay&amp;lt;/refreshType&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
    &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
    &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I went ahead and tried adjusting it to the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
   &amp;lt;title&amp;gt;Active Events (Last 5 minutes)&amp;lt;/title&amp;gt;
   &amp;lt;table&amp;gt;
     &amp;lt;search&amp;gt;
       &amp;lt;query&amp;gt;[search dv_severity NOT "Clear" state=Processed | fields dv_number ] NOT [search dv_severity="Clear" state=Closed | fields dv_number ]  | dedup dv_number | stats count by dv_node&amp;lt;/query&amp;gt;
       &amp;lt;earliest&amp;gt;-5m&amp;lt;/earliest&amp;gt;
       &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
       &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
       &amp;lt;refresh&amp;gt;2m&amp;lt;/refresh&amp;gt;
       &amp;lt;refreshType&amp;gt;delay&amp;lt;/refreshType&amp;gt;
&amp;lt;progress&amp;gt;
            &amp;lt;condition match="'job.resultCount' == 0"&amp;gt;
                &amp;lt;set token="panel_show"&amp;gt;false&amp;lt;/set&amp;gt;
            &amp;lt;/condition&amp;gt;
            &amp;lt;condition&amp;gt;
                &amp;lt;unset token="panel_show"/&amp;gt;
            &amp;lt;/condition&amp;gt;
        &amp;lt;/progress&amp;gt; 
     &amp;lt;/search&amp;gt;
     &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
     &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
     &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
     &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
     &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
     &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
     &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
   &amp;lt;/table&amp;gt;
 &amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now with all the preamble out of the way, this is what I'm trying to accomplish: If the ACTIVE events are found to be 0, can I make the panel disappear? Essentially, I only want the panel to "appear" on screen when it finds an ACTIVE alert. However, when I run my dashboard I still see the panel, with the "No Results Found".&lt;/P&gt;

&lt;P&gt;I hope that makes sense. Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 18:58:21 GMT</pubDate>
    <dc:creator>kiddsupreme</dc:creator>
    <dc:date>2020-09-29T18:58:21Z</dc:date>
    <item>
      <title>Hide a panel when the results of a search return</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326611#M21136</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm sure I am missing something simple, but thought I should ask. I am running a search that does the following:&lt;/P&gt;

&lt;P&gt;Fields&lt;BR /&gt;
- dv_node = The string that holds the hostname of devices&lt;BR /&gt;
- dv_number = A unique alert ID #&lt;BR /&gt;
- state = a value of "Processed" when opened and a value of "Closed" when closed&lt;BR /&gt;
- dv_severity = Clear means the alert has closed&lt;/P&gt;

&lt;P&gt;The first part of the search grabs the alerts that are active. The second part of the search grabs the alerts that are closed. If it finds a match between the dv_number of an ACTIVE alert in the 1st search &amp;amp; the dv_number of a CLOSED alert in the 2nd search, eliminate that dv_number from the final count. This is because the logs we process may have many entries along the way, but there should be at LEAST 1 ACTIVE entry and 1 CLOSED entry in the logs (Since, if something alarms, it has to eventually clear right?).&lt;/P&gt;

&lt;P&gt;At this point, the only thing that should be showing up are active items. At this point, we run a dedup to eliminate those "many entries along the way" log. Basically, lets ignore everything that came after that initial alert, until a matching closed event is found. &lt;/P&gt;

&lt;P&gt;Finally, do a count by dv_node to get a # of active entries per hostname.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;panel&amp;gt;
  &amp;lt;title&amp;gt;Active Events (Last 5 minutes)&amp;lt;/title&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;[search dv_severity NOT "Clear" state=Processed | fields dv_number ] NOT [search dv_severity="Clear" state=Closed | fields dv_number ]  | dedup dv_number | stats count by dv_node&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;-5m&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
      &amp;lt;refresh&amp;gt;2m&amp;lt;/refresh&amp;gt;
      &amp;lt;refreshType&amp;gt;delay&amp;lt;/refreshType&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
    &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
    &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
    &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I went ahead and tried adjusting it to the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
   &amp;lt;title&amp;gt;Active Events (Last 5 minutes)&amp;lt;/title&amp;gt;
   &amp;lt;table&amp;gt;
     &amp;lt;search&amp;gt;
       &amp;lt;query&amp;gt;[search dv_severity NOT "Clear" state=Processed | fields dv_number ] NOT [search dv_severity="Clear" state=Closed | fields dv_number ]  | dedup dv_number | stats count by dv_node&amp;lt;/query&amp;gt;
       &amp;lt;earliest&amp;gt;-5m&amp;lt;/earliest&amp;gt;
       &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
       &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
       &amp;lt;refresh&amp;gt;2m&amp;lt;/refresh&amp;gt;
       &amp;lt;refreshType&amp;gt;delay&amp;lt;/refreshType&amp;gt;
&amp;lt;progress&amp;gt;
            &amp;lt;condition match="'job.resultCount' == 0"&amp;gt;
                &amp;lt;set token="panel_show"&amp;gt;false&amp;lt;/set&amp;gt;
            &amp;lt;/condition&amp;gt;
            &amp;lt;condition&amp;gt;
                &amp;lt;unset token="panel_show"/&amp;gt;
            &amp;lt;/condition&amp;gt;
        &amp;lt;/progress&amp;gt; 
     &amp;lt;/search&amp;gt;
     &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
     &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
     &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
     &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
     &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
     &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
     &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
   &amp;lt;/table&amp;gt;
 &amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now with all the preamble out of the way, this is what I'm trying to accomplish: If the ACTIVE events are found to be 0, can I make the panel disappear? Essentially, I only want the panel to "appear" on screen when it finds an ACTIVE alert. However, when I run my dashboard I still see the panel, with the "No Results Found".&lt;/P&gt;

&lt;P&gt;I hope that makes sense. Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326611#M21136</guid>
      <dc:creator>kiddsupreme</dc:creator>
      <dc:date>2020-09-29T18:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Hide a panel when the results of a search return</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326612#M21137</link>
      <description>&lt;P&gt;@kiddsupreme, you would need to read about depends/rejects attribute to understand how they work.&lt;BR /&gt;
When &lt;CODE&gt;depends&lt;/CODE&gt; is used with a visualization element, it shows the element only when token is set (could be any value) and hides when token is unset (is undefined or null).&lt;BR /&gt;
With &lt;CODE&gt;rejects&lt;/CODE&gt; the same behavior is reversed, i.e. when the token is set the element is hidden and when the token is unset the element is displayed.&lt;BR /&gt;
Refer to&lt;CODE&gt;Null Search Swapper&lt;/CODE&gt; example in &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;Splunk Dashboard Examples&lt;/A&gt; App or an &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/ContextualDrilldown#Show_or_hide_content"&gt;example with depends in Splunk Docs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In your case since you are setting the token when number of results returned is 0 you should also add the token as rejects which is missing in the code you have provided. Try the following code and confirm:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;panel rejects="$panel_show$"&amp;gt;
  ....
  ....
  ....
      &amp;lt;progress&amp;gt;
         &amp;lt;condition match="$job.resultCount$==0"&amp;gt;
             &amp;lt;set token="panel_show"&amp;gt;true&amp;lt;/set&amp;gt;
         &amp;lt;/condition&amp;gt;
         &amp;lt;condition&amp;gt;
             &amp;lt;unset token="panel_show"&amp;gt;&amp;lt;/unset&amp;gt;
         &amp;lt;/condition&amp;gt;
     &amp;lt;/progress&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: If you are on Splunk 6.5 or higher, you should use &lt;CODE&gt;&amp;lt;progress&amp;gt;&lt;/CODE&gt; search event handler. If you are on Splunk 6.4 or previous version you should use &lt;CODE&gt;&amp;lt;preview&amp;gt;&lt;/CODE&gt; search event handler instead.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 05:11:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326612#M21137</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-11T05:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Hide a panel when the results of a search return</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326613#M21138</link>
      <description>&lt;P&gt;Thank you; that is working perfectly. I did however need to remove the  after the  because Splunk's error message reads: "Unexpected close tag". Once I removed that tag, it worked as expected. I appreciate not only the solution, but your detailed explanation; it definitely helped me visualize how it works. Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 18:39:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326613#M21138</guid>
      <dc:creator>kiddsupreme</dc:creator>
      <dc:date>2018-04-11T18:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Hide a panel when the results of a search return</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326614#M21139</link>
      <description>&lt;P&gt;Okay, apparently I didn't have my XML quite lined up... once I fixed that, the  command worked as well.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 19:39:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Hide-a-panel-when-the-results-of-a-search-return/m-p/326614#M21139</guid>
      <dc:creator>kiddsupreme</dc:creator>
      <dc:date>2018-04-11T19:39:11Z</dc:date>
    </item>
  </channel>
</rss>

