如何将字符串时间戳列转换为 grafana 中的时间戳

How can I convert string timestamp column to timestamp in grafana

我在 grafana 中为 vertica 使用 PG 插件,因为 grafana 没有原生的 Vertica 插件

select date_trunc('hour', moment) as time,
       sum(netSlaes)              as netSales
from ba.table
group by time;

Grafana 表示:

Invalid type for column time, must be of type timestamp or unix timestamp, got: string 2019-05-28 22:00:00

但是当我使用 DataGrip 时 sql returns:

2019-05-28 05:00:00.000000  1456106.03030303
2019-05-28 11:00:00.000000  16463313.9090909
2019-05-28 13:00:00.000000  15796558.4818182
2019-05-28 14:00:00.000000  5134891.6969697
2019-05-28 20:00:00.000000  13058329.5909091
...

请帮助设置时间列的时间戳格式

尝试使用 DATE_PART 从您的列中提取 unix 时间戳(纪元),并将其转换为 INT

select date_part('EPOCH', date_trunc('hour', moment))::INT as time,
       sum(netSlaes)              as netSales
from ba.table
group by time;

P.S - 过去我试图让 PG Grafana 的插件与 Vertica 一起工作,也遇到了那种数据类型问题。如果我没记错的话,整数被认为是字符串有问题。

vertica 开发人员添加了他们的 grafana 插件:https://grafana.com/grafana/plugins/vertica-grafana-datasource/installation

大约 4 个月前