mblackstock / node-red-contrib-influxdb

Node-RED nodes to save and query data from an influxdb time series database
Other
64 stars 44 forks source link

msg.precision for v1.8 and 2.0 #129

Closed vdwpsmt closed 1 year ago

vdwpsmt commented 1 year ago

https://github.com/mblackstock/node-red-contrib-influxdb/issues/123

vdwpsmt commented 1 year ago

@mblackstock kind reminder. Is it possible to review this possible bug and according revision?

mblackstock commented 1 year ago

Apologies for the delay. Thank you for this.

This looks pretty simple, but it would be good to update the documentation in the output and batch nodes to reflect that this feature is supported in both versions now. A simple test flow that demonstrates the change would be helpful too.

vdwpsmt commented 1 year ago

@mblackstock ok, on updating and testing I realized that the modification will not work the way I wrote it. I'm not a specialist and not sure how to solve this. The problem:

on influx version_1x the precision is added as an argument to the write method. on influx version_18_flux and version_20 the precision is added as an argument on creating the write client, so before any message has arrived.
I don't know how to update the write precision on an existing client instance. And I don't suppose it's good practice to create a write client on every incoming message?

mblackstock commented 1 year ago

I see. It's been some time since I wrote this code. I suspect this is why the options to change the precision on every write is are only available on 1.x - because of the underlying library used. I suggest we close this PR and the associated issue with an explaination.

vdwpsmt commented 1 year ago

I checked some more things. I suspect it would be possible to change the precision by modifying the path. That's what's stated here: https://influxdata.github.io/influxdb-client-js/influxdb-client.writeapi.path.html I did a short test and this seems to work. So I suppose it would be possible to change the path on every incoming message. (Better would be to change it conditionally, if precision has changed compared to previous message).
For now, I fear it's not important enough to spend more time on it. So indeed, we'll keep it with this comment for now.