【问题标题】:How to show downsampled values in grafana ?如何在 grafana 中显示下采样值?
【发布时间】:2023-03-04 22:33:01
【问题描述】:

我有一个 influxdb,想在 grafana 上显示下采样值。

InfluxDB 版本:1.2

Grafana 版本:4.2

  • 我已经创建了一个 influxedb 数据库:

    > CREATE DATABASE "mydb3_rp"
    
  • 然后我创建了一个保留策略:

    > CREATE RETENTION POLICY "1week" ON "mydb3_rp" DURATION 1w REPLICATION 1
    
  • 然后我创建了连续查询:

    create continuous query "cq_10" on mydb3_rp begin 
      select mean(\*) into "mydb3_rp"."1week".:MEASUREMENT 
      from /.\*/ 
      group by time(10m),* 
    end
    
  • 然后我将一些数据放入数据库。当我完成并想使用 influx 命令行工具查看保存的值时:

    select * from cpu1
    name: cpu1
    time                 cluster        node  value
    ----                 -------        ----  -----
    2017-05-03T17:06:00Z cluster-2 node2 2.9552020666133956
    2017-05-03T17:07:00Z cluster-2 node2 -1.5774569414324822
    2017-05-03T17:08:00Z cluster-2 node2 0.16813900484349714
    2017-05-03T17:09:00Z cluster-2 node2 1.244544235070617
    2017-05-03T17:10:00Z cluster-1 node2 7.833269096274834
    2017-05-03T17:10:00Z cluster-2 node2 -5.440211108893697
    2017-05-03T17:11:00Z cluster-1 node2 -6.877661591839738
    and so on...
    
  • 现在我想看看,连续查询是否有效并进行了聚合:

    select * from "1week".cpu1
    name: cpu1
    time                 cluster        mean_value           node
    ----                 -------        ----------           ----
    2017-05-03T16:45:00Z cluster-1 1.074452901375393    node1
    2017-05-03T16:45:00Z cluster-2 1.477524301989568    node1
    2017-05-03T16:45:00Z cluster-1 0.8845193960173319   node2
    2017-05-03T16:45:00Z cluster-2 -0.6551129796659627  node2
    2017-05-03T16:50:00Z cluster-2 -1.6457347223119738  node1
    2017-05-03T16:50:00Z cluster-2 0.6789712320493559   node2
    ...and so on
    
  • 现在我进入 grafana 并定义一个这样的查询:

    FROM 1week cpu1
    select field(value)
    

有 - 没有数据点

【问题讨论】:

    标签: influxdb grafana


    【解决方案1】:

    我知道这个问题是两个月前提出的,但也许有人还在读这个。 我目前也在为此苦苦挣扎,并在我的案例中找到了一个有效的查询。在你的我认为应该是:

    select "mean_value" from "mydb3_rp"."1week"."cpu1" where $timeFilter
    

    如果您不想更具体,还有其他 where 条件。

    K.

    【讨论】:

    • 投反对票的人能否解释一下为什么这个答案没有用?反向引用连续查询显然有效,在这种情况下,要检索平均值,应该使用完全合格的测量。我认为这是正确的方法,并且在我的安装中效果很好。
    • 我在保留策略之前忘记了数据库名称,已更正。
    猜你喜欢
    • 2020-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-03
    • 2021-04-11
    • 2021-06-11
    • 1970-01-01
    • 2022-06-16
    相关资源
    最近更新 更多