【问题标题】:Influxdb querying values from 2 measurements and using SUM() for the total valueInfluxdb 从 2 个测量值中查询值并使用 SUM() 作为总值
【发布时间】:2017-09-18 16:44:44
【问题描述】:
select SUM(value) 
from /measurment1|measurment2/ 
where time > now() - 60m  and host = 'hostname' limit 2;

名称:测量 1

time                sum
----                ---
1505749307008583382 4680247

名称:测量 2

time                sum
----                ---
1505749307008583382 3004489

但是是否有可能获得 SUM(measurment1+measurment2) 的值,所以我只看到 o/p 。

【问题讨论】:

    标签: influxdb influxdb-python


    【解决方案1】:

    在涌入查询语言中不可能。它不支持跨测量的函数。

    如果这是您需要的,您可能有兴趣在 influx 之上分层另一个 API 来执行此操作,例如通过 Influxgraph 的 Graphite。

    对于以上内容,类似这样。

    /etc/graphite-api.yaml:

    finders:
      - influxgraph.InfluxDBFinder
    influxdb:
      db: <your database>
      templates:
        # Produces metric paths like 'measurement1.hostname.value'
        - measurement.host.field*
    

    启动graphite-api/influxgraph webapp。

    查询/render?from=-60min&amp;target=sum(*.hostname.value) 然后在标签host='hostname' 上为所有测量生成value 的总和。

    {measurement1,measurement2}.hostname.value 可用于将其限制为特定测量。

    NB - 性能方面(涌入),最好在同一测量中使用多个值,而不是在多次测量中使用相同的值字段名称。

    【讨论】:

      猜你喜欢
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 2017-08-29
      • 2020-11-03
      • 2020-10-03
      • 2019-07-27
      • 1970-01-01
      • 2016-11-23
      相关资源
      最近更新 更多