Splunk Search

How to convert a pie chart into a single value visualization when the search returns no results?

Chinmai
Explorer

Hello Guys,

I have a pie chart in my dashboard, so whenever the search returns nothing, the pie chart should convert into single value visualization showing count as 0. And if there are any results from the search, pie chart should remain as it is.
Currently it shows no results found whenever the search returns nothing.

Can anyone help me with this problem?

Many Thanks in advance.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Since the query is returning nothing, there is nothing to chart. Add this snippet to your search to force a count of zero when there are no results. Change the 'foo' and 'bar' fields to fields in your current query.

| appendpipe [ stats count | eval foo="Nothing found" | eval bar=0 | where count==0 | fields - count ] | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

Chinmai
Explorer

Thanks for your answer, but how will this convert pie chart into single value? this is in my dashboard panel, under chart tag the query is written

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It won't change the type of chart. You'll still see a pie chart, but that's better than "No results found", right?

---
If this reply helps you, Karma would be appreciated.
0 Karma

Chinmai
Explorer

when count is 0, its not showing pie chart, it is showing "numeric data required"

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Check the field names in the appendpipe command. You may have foo and bar mixed up.

---
If this reply helps you, Karma would be appreciated.
0 Karma

Chinmai
Explorer

nope, they are fine, and still same result:( is there any other way to display 0 whenever the search returns nothing?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

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