Pie chart from 2 columns: label x value

  • What Grafana version and what operating system are you using?
  • Grafana v7.5.4 (615c153b3a), Amazon Linux

Hi, I’m trying to get a simple pie chart working. Data looks like:

column_a | column_b
3430        | 21
3431        | 1
3432        | 3
...

Column A is used in the group by, and column B is the summed metric:

SELECT
  column_a,
  sum(column_b)
FROM mytable
WHERE
  created_at BETWEEN FROM_UNIXTIME(1652820137) AND FROM_UNIXTIME(1652830937)
GROUP BY column_a
ORDER BY UNIX_TIMESTAMP(created_at) DIV 60 * 60

This works fine with the Table visualization, but with Pie chart v2, I get both columns treated as separate series, which doesn’t make sense.

I tried to hide (Transform > Organize fields) column A, and then the chart does make sense, however now I don’t get the labels I need (i.e. the values from column A); instead each slice of the pie has the same label (“column_b”).

I used to use an older version of Grafana with graphite and pie charts used to be a piece of cake (no pun intended). This seems like an extremely simple use case but I’m struggling.

Pie chart was very young in 7.5.4. I would highly recommend trying a newer version. Here is a sample dashboard:

https://play.grafana.org/d/ktMs4D6Mk/5-bar-charts-and-pie-charts?orgId=1

if the issue is with the data model, then it’s best to share what your raw data looks like, either by inspecting the panel or taking a screenshot of the table panel