简体   繁体   English

带有 Postgresql 的 Grafana 时间序列:GROUP BY 不起作用

[英]Grafana timeseries with Postgresql: GROUP BY doesn't work

I have a table:我有一张桌子:

CREATE TABLE IF NOT EXISTS "case_closed" (
"case_id" varchar(256) NOT NULL,
"closed_at" TIMESTAMP WITH TIME ZONE,
"disposition" VARCHAR(128),
PRIMARY KEY ("case_id")
);

And in Grafana, I need to display more than one graph, one per each 'disposition' value (I have 2 different disposition values at the moment).在 Grafana 中,我需要显示多个图表,每个“配置”值对应一个图表(目前我有 2 个不同的配置值)。

I'm trying this query:我正在尝试这个查询:

SELECT
  $__timeGroupAlias(closed_at, $__interval),
  disposition AS "metric",
  COUNT(*) AS "value"
FROM case_closed 
WHERE 
  $__timeFilter(closed_at)
GROUP BY 1,2
ORDER BY 1

And it gives me this ugly picture with only one single graph:它给了我这张只有一张图的丑陋图片: 在此处输入图像描述

I searched here and from all I can see my query seems to be okay, but it still doesn't work.我在这里搜索,从我所看到的所有内容来看,我的查询似乎没问题,但仍然无效。 Maybe I'm missing something and it's not the query but some settings??也许我遗漏了一些东西,这不是查询而是一些设置?

Solved: There was a small thing in the Query Builder (not sure why I didn't see it in any documentation):已解决:查询生成器中有一个小问题(不知道为什么我在任何文档中都没有看到它): 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM