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

Parses InfluxDB Line Protocol to JSON and vice versa.
MIT License
1 stars 2 forks source link

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

Open wz2b opened 2 years ago

wz2b commented 2 years ago

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