Grafana 图表按天还是按月分组?
Grafana charts grouped by day or month?
由于无法按日期对图表进行分组,我被图表困住了。我正在使用日期和计数器使我的查询可视化,问题是将它们添加到 grafana 看起来像这样。
我的问题:
查询:
select
to_char(created,'yyyy-mm-dd') as "time", count(created) as created
from
[table]
group by
to_char(created,'yyyy-mm-dd')
我对每个图使用类似的查询,以可视化为我的问题图像。
我怎样才能让它看起来像这样?
使用一些 $__timeGroup*/$__unixEpochGroup*
宏(这取决于列 created
类型)- https://grafana.com/docs/grafana/latest/datasources/postgres/#macros。示例:
SELECT
$__unixEpochGroupAlias(created, 30d),
count(*) AS "count"
FROM $table
WHERE
$__unixEpochFilter(created)
GROUP BY 1
ORDER BY 1
最后你需要自己写 SQL 来按日历月分组。
由于无法按日期对图表进行分组,我被图表困住了。我正在使用日期和计数器使我的查询可视化,问题是将它们添加到 grafana 看起来像这样。
我的问题:
查询:
select
to_char(created,'yyyy-mm-dd') as "time", count(created) as created
from
[table]
group by
to_char(created,'yyyy-mm-dd')
我对每个图使用类似的查询,以可视化为我的问题图像。
我怎样才能让它看起来像这样?
使用一些 $__timeGroup*/$__unixEpochGroup*
宏(这取决于列 created
类型)- https://grafana.com/docs/grafana/latest/datasources/postgres/#macros。示例:
SELECT
$__unixEpochGroupAlias(created, 30d),
count(*) AS "count"
FROM $table
WHERE
$__unixEpochFilter(created)
GROUP BY 1
ORDER BY 1
最后你需要自己写 SQL 来按日历月分组。