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>

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
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

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...