Show particular column as Label in pie chart

  • What Grafana version and what operating system are you using?
    v8.3.3 (30bb7a93ca)

  • What are you trying to achieve?
    Display legend in the pie chart

  • How are you trying to achieve it?
    Showing legend as the right-aligned table.

select
  now() as 'time_sec',
	p.name as 'Plan',
  count(*) as 'Count'
from plans_userplan up
inner join plans_plan p on up.plan_id = p.id
group by p.name

  • What happened?
    Legend labels are prepended with Count

  • What did you expect to happen?
    Set a particular column as a legend instead of appending two columns
    Remove Count from the legend label.

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

What choices are displayed under Legend values?

The values under Legend

Which are shown perfectly in the legend table. But my query is about Count prepend to the legend label

I think you will have to create a Regex to remove the “Count” word.

Here is a thread where Regex is explained a bit further.

Try this:

select
now() as ‘time_sec’,
p.name as ‘Plan’,
count(*)
from plans_userplan up
inner join plans_plan p on up.plan_id = p.id
group by p.name

@dueni0 removing alias from count(*) is now showing as

Screen Shot 2022-05-25 at 8.49.05 AM

Thanks, @grant2, using regex in Transform worked for me