Generate CSV-file from Influx database

I've been struggling with the following for a while now.

A growing Influx DB "luchtdruk" contains the fields luchtdruk and tijd (see picture) over the last weeks. I would like to generate a comma separated CSV file from this database with only two columns namely tijd and luchtdruk and then only the last 24 hours.

Can someone help me with this?

DB

The influx docs are not bad in this area, with many examples. Start with something like
select "luchtdruk","tijd" from .....
I hope that tijd is not another representation of the time field, if it is then it should not really be there, derive it from the time value when you need it.

https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/#the-basic-select-statement

Thanks. Selecting data from Influx is not the problem, I know how to do that. My problem is how to select from Influx within Node Red. Besides the Influx database is what it is, I can't change it.

The reason there is a field tijd is because an Influx timestamp is stored in nanoseconds while a javascript timestamp is stored in milliseconds. This causes problems when generating a CSV-file so the extra field tijd is there.

I had not noticed any difficulty dividing by 1 million in node-red.

That is the easy bit, which is why I assumed that the sql query was the problem. node-red-contrib-influxdb (node) - Node-RED

Thanks Colin. I believe without a doubt you are right about the tijd field but that is not the problem. The point is that I want to convert the measurements of the last 24 hours to a CSV file. In the flow below I select the last 20 measurements and that works fine but that should be the last 24 hours.

So it is the SELECT statement that you need help with. You need to use a WHERE clause to select for the the last 24 hours. Have a look in the docs I linked to.

Now it's clear to me that the node uses the same commands as Influx DB. I didn't know that and I didn't understand you. Now solved by using the query below and it works fine :slight_smile:

SELECT "tijd","luchtdruk" FROM "luchtdruk" WHERE time > now() - 24h

All the node does is to pass the statement on to Influx and give you the results.

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