问题描述
我是 Grafana 的新手。我试图绘制的数据以表格格式显示良好,但当我尝试使用 Graph 进行可视化时,它显示无法绘制数据。
表格数据如下:
count() t
----------------------------
54 2020-12-02 09:00:00
387 2020-12-02 09:01:00
1462 2020-12-02 09:02:00
这是查询:
SELECT
count(),$dateTimeCol as t
FROM $table
where date='2020-12-02'
GROUP BY t
ORDER BY t
我使用 Grafana/7.1.4 和 clickhouse 作为数据源。我错过了什么?
提前致谢
解决方法
应该使用$timeSeries-宏:
SELECT
$timeSeries t,count()
FROM $table
WHERE date='2020-12-02' /* should be used 'WHERE $timeFilter' ? */
GROUP BY t
ORDER BY t
让我们模拟测试数据集:
SELECT
$timeSeries as t,count()
FROM (select (now() - rand() % 24*60*60) AS dt from $table limit 1024)
WHERE $timeFilter
GROUP BY t
ORDER BY t
定义查询参数 - FROM 为 system.numbers,Column:DateTime 为 dt:
并获取 24 小时范围内的图表: