【问题标题】:How can I convert string timestamp column to timestamp in grafana如何在grafana中将字符串时间戳列转换为时间戳
【发布时间】:2019-06-18 09:09:46
【问题描述】:

我在 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 会返回:

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
...

请帮忙说明时间列的时间戳格式

【问题讨论】:

    标签: timestamp grafana vertica


    【解决方案1】:

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

    大约 4 个月前

    【讨论】:

      【解决方案2】:

      尝试使用 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 一起工作,也遇到了这类数据类型问题。如果我没记错的话,被认为是字符串的整数存在问题。

      【讨论】:

      猜你喜欢
      • 2020-11-22
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多