InfluxDB: Flux - Error: Cannot divide by zero: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „== Error == '''Cannot divide by zero''' == Cause == ''This error occurs because your data/metric points have different types.'' ''Mostly the fault is that yo…“) |
Admin (Diskussion | Beiträge) |
||
Zeile 4: | Zeile 4: | ||
== Cause == | == Cause == | ||
− | ''This error occurs because your data/metric points have different types.'' | + | ''This error occurs because your data/metric points have different types.'' <br> |
''Mostly the fault is that your data contains "0" and the datatype of "0" = "Integer". But the other datatypes are "Float" and that's the reason you can't calculate.'' | ''Mostly the fault is that your data contains "0" and the datatype of "0" = "Integer". But the other datatypes are "Float" and that's the reason you can't calculate.'' | ||
Version vom 17. Februar 2021, 14:12 Uhr
Error
Cannot divide by zero
Cause
This error occurs because your data/metric points have different types.
Mostly the fault is that your data contains "0" and the datatype of "0" = "Integer". But the other datatypes are "Float" and that's the reason you can't calculate.
Solution
- Add following map() function to your query (example you have two fields (field1 & field2)):
|> map(fn: (r) => ({ r with qos_usage_percent: if not exists r.field1 or r.field1 == 0.0 then 0.0 else if not exists r.field2 or r.Io_Quota_field2 Replenishment_Rate == 0.0 then 0.0 else r.field1 * r.field2 }))
More information's: https://community.influxdata.com/t/flux-how-to-handle-division-by-zero/16704