【问题标题】:Average of 2 Sums in Flux query in InfluxInflux 中 Flux 查询中 2 个 Sums 的平均值
【发布时间】:2021-10-06 06:17:43
【问题描述】:

我需要计算错误率,公式是countError/count

我已经尝试加入,但有点卡住了该做什么

count = from(bucket: "stress")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["application"] == "application name"
        and  r["_field"] == "count"
        and  r["transaction"] == "all")
  |> sum(column: "_value") 

  countError = from(bucket: "stress")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["application"] == "application name"
        and  r["_field"] == "countError"
        and  r["transaction"] == "all")
  |> sum(column: "_value")


join(
tables: {count,countError},
on: ["_value"]
)

【问题讨论】:

    标签: influxdb flux-influxdb


    【解决方案1】:

    经过更多的尝试,我想通了。我需要使用地图

    count = from(bucket: "stress")
      |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
      |> filter(fn: (r) => r["application"] == "application name"
            and  r["_field"] == "count"
            and  r["transaction"] == "all")
      |> sum(column: "_value") 
    
    
      countError = from(bucket: "stress")
      |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
      |> filter(fn: (r) => r["application"] == "application name"
            and  r["_field"] == "countError"
            and  r["transaction"] == "all")
      |> sum(column: "_value")
    
    join(
    tables: {cn:count,ce:countError},
    on: ["_measurement"]
    )
      |> map(fn: (r) => ({
          _value: r._value_ce / r._value_cn
        })
      )
    

    【讨论】:

      猜你喜欢
      • 2019-03-12
      • 2015-06-12
      • 1970-01-01
      • 1970-01-01
      • 2010-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-14
      相关资源
      最近更新 更多