This my error message coming from InfluxDB node: Error: A 400 Bad Request error occurred: {"error":"partial write: points beyond retention policy dropped=1"}
This my DB retention configuration: ( I have deleted autogen retention policy)
Thank you for your answer now node-red recognize that it's a timestamp and display it as a date (without any other node as moment) but I still have the same problem :Error: A 400 Bad Request error occurred: {"error":"partial write: points beyond retention policy dropped=1"}
Is it ok if you don't give it the timestamp, so that influx adds the timestamp? I know you don't want to do this, just checking whether it is ok otherwise.
Also I notice that the influxdb out node does not say that you can include a timestamp. Have you tried the same thing using the batch node, which does say a timestamp can be included.
Yes it's working very well when I don't change my timestamp but I'm receiving one payload every hour but each payload contains 3 messages (one measurement every 20 minutes).
I have just checked the InfluxDB contrib info and the time can be injected I think:
You are right it was a mistake, finally I have choosen the batch node and I'm injecting a message according to the influx node doc(the last exampke) but I still have the same error message
Error: A 400 Bad Request error occurred: {"error":"partial write: points beyond retention policy dropped=3"}
From the error message, it looks like the timestamps you've provided to the Batch output node are numbers, so these will be passed in to InfluxDb for parsing. Since InfluxDb uses nanosecond precision by default, these millisecond dates may be outside of your retention policy, causing this error to be thrown.
Have you tried using Javascript Date objects for your timestamps as in the example? E.g. "timestamp": new Date(1564128384000) rather than "timestamp":1564128384000? This should cause the library to convert to the right precision. I think another option might be to specify the precision (e.g. 'ms') with the writes as in the writePoints documentation.
If I let my time-stamp in miliseconds Node Red recongnize automatically that it's a timestamp and in the debug I can display it as a date.
If I multiply by 1000 (to have a nanoseconds) node red don't recognize that it's a date.
Solution: To use a batchnode and using the Date object using a miliseconds precision
You only need to multiply it by 1000 when sending it to the influx node. Leave it as a javascript date when using it elsewhere. That would be an alternative solution.
Somewhat late to the party, but I had pretty-much the same requirement - and the same frustration, trying to get influxdb to accept input with a time value of my choosing. (I kept getting an error message that said the time wasn't between the permitted ranges, while quoting back at me my value, which clearly was!)
Long story short:
use the influx batch node;
leave the time precision in the node as Default;
create a payload that's an array of objects, where every object is one row to add to the db;
send the time value as an integer number of nanoseconds (irrespective of whatever precision you use).
By way of example, here's the (working!) test payload I constructed:
msg.payload = [
{ // first row
measurement: "test",
fields: {
numValue: 10,
randomValue: Math.random()*10,
strValue: "message1",
mytime: new Date().getTime()
},
tags: {
tag1:"sensor1",
tag2:"device2"
},
timestamp : new Date().getTime() * 1e6 // time now; convert milliseconds to nanoseconds
},
{ // second row
measurement: "test",
fields: {
numValue: 20,
randomValue: Math.random()*10,
strValue: "message2",
mytime: new Date().getTime() + 6000000
},
tags: {
tag1:"sensor1",
tag2:"device2"
},
timestamp : (new Date().getTime() + 6000000 ) * 1e6 // (arbitrary) 6000s in the future
}
];
return msg;
I also had problems setting an arbitrary timestamp using the influx out node.
I sorted it out by setting the Time Precision setting to ms and feeding the node with an array of array containing an object with the fields and values :
I know it adds a bit more CPU overhead, but when dealing with timestamps going to influx, I prefer to simply throw a node-red-contrib-moment node in the flow with the output format set to "x" (lower case is important for the formatting.) This will get your timestamp into a format that influx likes.
Here's an example payload structure I'm sending. The output of the moment node would be going to msg.time before the flow heads into a function that looks as follows:
I then send the output of this to a join node (my source data for this flow is coming from a CSV file, so it already has the split metadata) to turn it into an array of arrays.
The OP could not write data to an InfluxDB using the Influx Out node.
There were some discussions regarding the time format, and then someone (you ?) said that writing multiple fields at a time must be done using the batch node. That's not true. You must provide an array of array of objects containing the data (fields and tags).
@JayDickson : the timestamps are not that complicated. Javascript date-related functions have a resolution to the ms. Simply configure the influx nodes ("Time Precision") to the one you use in your project.