Nanosecond Precision with InfluxDB

I am struggling with ns resolution timestamps from an influxDB (node-red-contrib-influxdb). The data is high-resolution acceleration data with a sampling frequency of several kHz. To make exact timestamps I would need ns resolution. Saving the data to the database works and in the DB it is stored with correct precision (see picture). After the query, the last digits are replaced by zeros. Any guesses what I can do in this particular case?

Thanks in advance!

How it is stored in the DB:
grafik

I'm still somewhat new (so I could be way off), but could you be running into an issue with Number.MAX_SAFE_INTEGER - JavaScript | MDN

Your msg.payload.results[0].series[0].values[7][0] is set to:

1658150533469000000

but the max is

9007199254740991

I think you are right! Thanks a lot! Unfortunately I cant really change that. I found the part in the influx node-code:

                if (rawOutput) {
                    var queryPromise = client.queryRaw(query, queryOptions);
                } else {
                    var queryPromise = client.query(query, queryOptions);
                }

                queryPromise.then(function (results) {
                    msg.payload = results;
                    send(msg);
                    done();

I think I need to change the type of results to string or BigInt. Unfortunately this is an object. Any idea how to solve that?

What are you going to do with the data once you get it into node-red?

Also what do you see if you select Raw Output in the Influx In node?

I get the data via MQTT and want to store it in a database first. Than you should be able to retrieve the data from the DB via dashboard and make a csv export.
The picture in the first post shows the raw output. Below is the formatet output. Then it also formats the timestamp another way:
grafik

If the influxdb node is getting in the way, don't forget that you can submit data to InfluxDB directly via its REST API. The line protocol is text rather than anything else so you can submit data to ns precision that way.

InfluxDB line protocol tutorial | InfluxDB OSS 1.8 Documentation (influxdata.com)

Why are you getting it out of influx and then storing it in a database? It is already in a database (influx).

If you do need to store it in another db then will that db support those large numbers?

What are you going to do with the csv export?

As @TotallyInformation says, if you need to fetch the full precision timestamp you should be able to do it directly rather than using the influxdb node.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.