Dashboards & Visualizations

Displaying string value in pie chart

gmishra
New Member

I use multiple saves searches from different chart to display overall application health status. The chart works fine for me accept it only shows colors. I am working to display the string value (green, yellow, red) on the pie chart but it doesnt work as expected.

Splunk pie chart (somehow) never displays the color name on the chart. I was wondering if there is a way to display the value on the chart. I tried to use the single value chart but looks like it adds colors only for numerical values and not for string.

Please help me understand if anyone of you have achieved this in Splunk. Here are some additional details.

<panel>
  <chart>
    <title>Agent Portal</title>
    <search>
      <query>
        | savedsearch "A" 
        | append [ | savedsearch "B"] 
        | append [ | savedsearch "C"]
        | append [ | savedsearch "D"]
        | append [ | savedsearch "E"]
        | append [ | savedsearch "F"]
        | append [ | savedsearch "G"] 
        | eval overall_health = min(availability_severity, performance_severity, apdex_severity, report_GCPA_severity, report_NBP_severity, report_OReq_severity, report_PGA_severity) 
        | stats min(overall_health) as severity 
        | eval color=case(severity="1","red",severity="2","yellow",severity="3","green") 
        | chart count by color
      </query>
      <earliest>-15m</earliest>
      <latest>now</latest>
      <refresh>60s</refresh>
      <refreshType>delay</refreshType>
    </search>
    <option name="charting.chart">pie</option>
    <option name="charting.chart.showLabels">0</option>
    <option name="height">100</option>
    <option name="charting.fieldColors">{"red":0xff0000,"yellow":0xffc300,"green":0x65a637}</option>
    <drilldown>
      <link target="_blank">/app/search/application_health__agent_portal</link>
    </drilldown>
  </chart>
</panel>
Tags (2)
0 Karma

koshyk
Super Champion

Similar question already answered in here: https://answers.splunk.com/answers/71090/how-to-display-the-count-in-piechart-as-labels.html

Basically, Simple two options
1. show as percent

 <option name="charting.chart.showPercent">true</option>

2.Trick to include the value as a string

.. | stats count by severity | eval severity_slice = count + " " + severity | fields severity_slice, count
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...