Dashboards & Visualizations

Why my condition token not working ?

mah
Builder

Hi, 

I want to use condition to set a "show" OR a "hide" panel (if no result) : 

<row depends="$panel_hide$">
<panel id="no_result">
<title>List</title>
<html>
<style>
#clear .dashboard-panel {background: white;}
</style>
<center>
<h2>No result<i class="icon-check icon-no-underline" style="font-size:100%;color:#65a637;"/>
</h2>
</center>
</html>
</panel>
</row>
<row depends="$panel_show$">
<panel>
<title>List</title>
<table>
<search>
<query>index=A sourcetype="B" id=*
| table id name start end
| sort - start</query>
<earliest>-10m</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
<finalized>
<condition match="$job.resultCount$&gt;0">
<set token="panel_show">true</set>
</condition>
<condition>
<set token="panel_hide"></set>
<unset token="panel_show"></unset>
</condition>
</finalized>
</search>
<option name="count">20</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="refresh.display">progressbar</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>

This code not working... It gives me both panel : 

mah_0-1609068634116.png

 

What it is wrong with my code ?

Thanks for help.

Labels (1)
Tags (1)
0 Karma

renjith_nair
Legend

Add unset token for the panel_hide in the first condition

ie.

<finalized>
 <condition match="$job.resultCount$&gt;0">
  <set token="panel_show">true</set>
  <unset token="panel_hide"></unset>
 </condition>
 <condition>
  <set token="panel_hide"></set>
  <unset token="panel_show"></unset>
 </condition>
</finalized>

 

Happy Splunking!
0 Karma

mah
Builder

That was the solution ! Thank you. 

Is there a way to create a condition which says : if the table command does not return result so display a massage like "The list is empty" without a panel hide like I did ?

 

0 Karma

renjith_nair
Legend

You may user appendpipe

e.g.

|makeresults count=1|eval data="Something"
|appendpipe [|stats count|where count=0|eval data="The list is empty" |fields - count]

Run this search and change the count value to 0 see the difference. Appreciate 👍 if the solution/replies helps

 

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...