【问题标题】:How to run Grafana with QuestDB如何使用 QuestDB 运行 Grafana
【发布时间】:2021-01-07 09:50:50
【问题描述】:

我已经在 QuestDB 中导入了一个演示数据集,我可以从控制台成功查询它。我正在使用 Grafana 构建仪表板来测试可视化。

我的 QuestDB 安装在端口 9000 上运行,我可以毫无问题地导入它:

curl -F data=@weather.csv http://localhost:9000/imp

我正在运行以下失败的查询:

SELECT timestamp as time,
       avg(visMiles) AS average_visibility
FROM 'weather.csv'
WHERE $__timeFilter(timestamp)
SAMPLE BY $__interval
LIMIT 1000

我得到的错误是

pq: unknown function name: between(TIMESTAMP,STRING,STRING)

我正在使用他们的examples 中提供的数据集。

【问题讨论】:

    标签: grafana questdb


    【解决方案1】:

    QuestDB 依赖于在表创建期间指定的指定时间戳。如果将 curl 请求作为 URL 参数提供给一个名为“timestamp”的列,这不会导致错误:

    curl -F data=@weather.csv http://localhost:9000/imp?timestamp=timestamp
    

    另一个选项是在SELECT 操作期间,timestamp() 函数可以动态指定一个。如果您使用 curl 导入且未设置指定时间戳,则有两种选择:

    1. 修改您的查询以在您要指定的列上使用timestamp()

      SELECT timestamp as time,
             avg(visMiles) AS average_visibility
      FROM (‘weather.csv’ timestamp(timestamp))
      WHERE $__timeFilter(timestamp)
      SAMPLE BY $__interval
      LIMIT 1000
      
    2. 创建一个新表,该表是原始数据集的副本,但在创建期间指定时间戳。使用 ORDER BY 是因为演示数据集具有无序的时间戳条目:

      create table temp_table as (select * from ‘weather.csv’ order by timestamp) timestamp(timestamp);
      

      不要查询您的原始数据集,而是使用temp_table

      SELECT timestamp as time,
        avg(visMiles) AS average_visibility
      FROM temp_table
      WHERE $__timeFilter(timestamp)
      SAMPLE BY $__interval
      LIMIT 1000
      

    如果您需要有关使用指定时间戳的更多信息,QuestDB concepts / timestamp docs 页面有更多详细信息。

    编辑:还有一些与此主题相关的资源,例如 guide for Grafana with QuestDBGitHub repo with docker-compose

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多