-
您的查询没有为Grafana返回正确的时间序列数据-时间字段不是有效的时间戳,因此不要仅提取
start_timestamp
(我希望是
timestamp
数据类型和值以UTC为单位)
-
添加位置
time
条件-使用Grafana的宏
__timeFilter
-
使用Grafana的宏
$__timeGroupAlias
按小时分组
SELECT
$__timeGroupAlias(start_timestamp,1h,0),
avg(marketprice) as value
FROM doc.el_marketprices
WHERE $__timeFilter(start_timestamp)
GROUP BY 1
ORDER BY 1
SELECT
$__timeGroupAlias(start_timestamp,1h,0),
extract(HOUR from start_timestamp) as "metric",
avg(marketprice) as value
FROM doc.el_marketprices
WHERE $__timeFilter(start_timestamp)
GROUP BY 1
ORDER BY 1
然后将其可视化为直方图。记住Grafana是为时间序列数据指定的,所以您需要适当的时间戳(不仅是提取的小时数,最终您可以伪造它),否则您将很难在Grafana中可视化非时间序列数据。这个第二个查询可能无法正常工作,但它至少给了您一些想法。