我对 Grafana 和 Postgres 很陌生,可以在这方面使用一些帮助。我在 PostgreSQL 中有一个带有温度预测的数据集。dump_date
同一参考日期在全天的不同时间点(用 表示)发布多项预测。假设:今天 06:00 和今天 12:00 发布明天的预报(时间用 表示start_time
)。现在我想使用 Grafana 将温度预测可视化为时间序列。但是,我只想可视化最新发布的预测(12:00),而不是两个预测。我以为我会使用 DISTINCT ON() 仅从该数据集中选择最新发布的预测,但不知何故,对于 Grafana,这没有响应。我在 Grafana 中的代码如下:
SELECT
$__time(distinct on(t_ID.start_time)),
concat('Forecast')::text as metric,
t_ID.value
FROM
forecast_table t_ID
WHERE
$__timeFilter(t_ID.start_time)
and t_ID.start_time >= (current_timestamp - interval '30 minute')
and t_ID.dump_date >= (current_timestamp - interval '30 minute')
ORDER BY
t_ID.start_time asc,
t_ID.dump_date desc
但是,这不起作用,因为我收到消息:'AS 处或附近的语法错误'。我应该怎么办?