0

I need to calculate error rate the forumula is countError/count

I have tried joining but kind of stuck what to do post that

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"]
)
Ayansplatt
  • 51
  • 4

1 Answers1

2

After some more trial i figured it out. I needed to use map

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
    })
  )
Ayansplatt
  • 51
  • 4