Node-Red to Influxdb Batch Node

Hi All,
I am in the process of converting flow data from a wetland monitoring site that I want to display in Grafana from an Infludb database. The data is received daily in the form of an excel sheet from the provider which I isolate and parse through a number of nodes. I believe I am almost there but am stumped at the final hurdle. The 'measurements' are coming through to Grafana but the data points are absent. The debug output from one of the measurements (there are 5) looks like this:
{"measurement":"site1dailyvol","fields":{"sp1dailyvol":25.18999863},"tags":{"location":"sp1"},"timestamp":1564293600000}, .................

Anyone have suggestions that would enable the data points to display?

Also the function code to set the variables looks like this:
var site1 = msg.payload[0].rank;
var dailyvol1 = parseFloat(msg.payload[0].value);
var timestamp1 = Date.parse(msg.payload[0].date);

And the msg.payload:
msg.payload =
measurement: "site1dailyvol",
fields: {
sp1dailyvol: dailyvol1
timestamp: timestamp1

Have you tried running the influxdb command line client to check the points are getting into the db ok?

Hi @jasjnr
Before getting charts in Grafana, make sure you have data in IndluxDB.
Do you see the data in your measurement?

use <your_DB>
select * from <your_measurement> limit 10

If none, then the problem is is posting data to the DB.

It does appear the data is being entered:

select * from site1dailyvol limit 10
name: site1dailyvol
time location sp1dailyvol

1556690400000 sp1 60.43000031
1556776800000 sp1 29.67000008
1556863200000 sp1 26.94999886
1556949600000 sp1 28.86999893
1557036000000 sp1 29.01000023
1557122400000 sp1 31.84999847
1557208800000 sp1 28.70999908
1557295200000 sp1 47.66999817
1557381600000 sp1 45.43000031
1557468000000 sp1 25.84000015

Your timestamps have not got nearly enough zeros on them, mine look like
though I must say I am surprised to see so many on mine

Thanks Colin. In the function node prior to the Influxdb Batch node I use the following to convert the date record to unix time:
var timestamp1 = Date.parse(msg.payload[0].date);

Yes I saw that, and it looks correct. I haven't used the batch node just the basic one, but I do remember at least one other post where the timestamps did not seem to be going in correctly using the batch node.
The link below does say they should be in nanoseconds, which I think agrees with the numbers I have. Try multiplying by 10^6 and see what happens. Something like
var timestamp1 = Date.parse(msg.payload[0].date).getTime()*1000000

Well spotted Colin!
I updated the code with another variable to then multiply and it worked a treat:

var timeParse1 = Date.parse(msg.payload[0].date);
var timestamp1 = timeParse1*1000000;

Thanks for your help!

It would be worth putting an issue on the node's github page pointing out that the readme needs clarification of what the timestamp should be.

I have submitted an issue

if you remove all "group by" arguments, the chart will appear as it is, without additional changes.

Can you explain why? Given that it works as it is if the timestamp is passed in microseconds?

Given advice isn't a must. It's personal preference. The reason behind it: less code, less bugs.
However, common thumb rule is good enough: if existing code works, don't touch it :slight_smile:

I don't understand why removing the "group by" would have fixed the problem, which appeared to be to do with the way the data was being added to influx, not to do with the grafana.