wz2b/node-red-contrib-influxdb-line-protocol

Bug writing all exact integers as integers blows up influxdb if the field was already written as a float

Opened this issue · 0 comments

wz2b commented

I know we have a previous discussion here and I plan to fix this ... but I don't want to lose track of it.

Here you test if a number is an integer and if so you emit it as an int, but the problem is if you do that if the number has ever been a fraction influx will fail to insert it. Example:

Mar 15 19:58:34 testbed telegraf[1798106]: 2022-03-15T19:58:34Z E! [outputs.influxdb_v2] Failed to write metric (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "scf" on measurement "airflow" is type integer, already exists as type float dropped=4

This because scf was 1.1 for a while, then it went to 0. This library wrote it as scf=1.1 the first time, then scf=0i the second time. You cannot do that with influxdb...

https://github.com/opatut/node-red-contrib-influxdb-line-protocol/blob/738719a1b820414757b74876adfa94c34c2e65ee/influxdb-line-protocol.js#L3