Grafana Pie Chart usage

Hi,

I am new using Grafana. I need to create a pie chart in Grafana from a postgreSQL datasource.

My table has the structure (time, user, count), and I would like to represent the maximum number of count per user, so I would need to have one section of the pie per user. Is that possible?

I have already read this topic regarding the pie chart:

but I couldn’t manage to get the desired result.

I have tried:
SELECT
now() as time,
MAX(count)
FROM
shema.table
GROUP BY user

But I only get all the pie in the same section with the value of the max count for all user, not the maximum per user.

Thanks in advance!! :slight_smile:

Hi Dharma77,
This is related with postgres, not to grafana.
Can solved it in the following way:

SELECT
now() as time,
MAX(count) as value, 
user as metric
FROM
shema.table
GROUP BY user
1 Like

Thanks! Problem solved :smiley:

Hello, I have some problems with the pie chart. I use v7.5.5, and then use the following statements:

SELECT
  now() as time,
  principal as metric,
  count(1)  as value
FROM jhi_persistent_audit_event
GROUP BY principal

The results are as follows:

The tag name of the pie chart I want to display is the value of metric, such as admin, but the tag name it displays is not what I want to display. As shown in the figure below:

What did I do wrong?How can I modify it

What grafana version are you using?

The version I used was 7.5.5, and I later tried to use 8.0.2, but the new version didn’t have this problem