InfluxDB insert data

Hi all,

I'm working with node red about 5 days ago, so I'm newbie.

Why this flow didn't insert any record in influxdb? What do I need to do to insert records to influxdb?

[{"id":"857e5728.5e74a8","type":"function","z":"c0a89205.8fc5e","name":"","func":"msg.payload = {\n    numValue: 123.0,\n    strValue: \"message\",\n}\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":740,"wires":[["46eec075.1724d"]]},{"id":"46eec075.1724d","type":"influxdb out","z":"c0a89205.8fc5e","influxdb":"38e13ac5.ff85f6","name":"cm005","measurement":"cm005","precision":"","retentionPolicy":"rp_casa_oneyear","x":770,"y":740,"wires":[]},{"id":"89c16b41.8dd0e8","type":"inject","z":"c0a89205.8fc5e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":740,"wires":[["857e5728.5e74a8"]]},{"id":"38e13ac5.ff85f6","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"casa","name":"Influxdb","usetls":false,"tls":""}]

The measurement was created, but is it empty.

Thank you very much,
Rui

PS: I exported and paste here again, in case something is incorrect, in my node red instalation I could import without errors...

There are some influxbd flows that you can import available at flows.nodered.org that might show you where you are going wrong.
(i’m not infront of a laptop at the mo)

@rchen - Rui, Your flow is not importable due to errors in it, so can't really load it up to test.

If you look at the contents of the function node, is there a syntax error displayed - probably :warning: icons in the margin?
If so, hover over them and read what the error is.

How do you know?
Did you checked it on the Influx command line?
Or is just your chart empty....

It's strange that it cannot be imported. The flow seems to be erroring around this section of your flow - strValue: "message",.

I'm assuming it's because the string quotes are not escaped like this;
strValue: \"message\",

??

error

YEs, I check on the command line.

use casa;
select * from cm005;

Empty result, no error on debug...

Thank you for that info, but I already search, but I can't understand how can I create a new object which can be used in influxdb output. What is the structure needed to it?

Rui

My function appear like this :

image

In logs I got an error 204 (empty content)

Sep 15 21:40:51 raspberrypi influxd[10711]: [httpd] 127.0.0.1 - master [15/Sep/2019:21:40:51 +0100] "POST /write?db=casa&p=%5BREDACTED%5D&precision=n&rp=rp_casa_oneyear&u=master HTTP/1.1" 204 0 "-" "-" 1b533658-d7f9-11e9-85da-dca63211e774 17585

Try adding a catch node connected to a debug (display complete msg object) to see if anthing shows up.

Remove the comma after "message".
Last value shouldn't have a comma.

msg.payload = {
    numValue: 123.0,
    strValue: "message"
}
return msg;

@rchen you keep editing your original flow.
The first version could not be imported, why is that?

I don't know why...

New info...

I used an example from original influxdb node and compared it. The difference was in advanced query options. After some tests, If I disabled advanced query options, it is inserted without problems, if I select advanced query options, choose any value in time precision and specified an existing policy, I didn't got any error, but I didn't got any value in measurement.

Executed with success :
image

Executed without success (but without any error) :
image

Any one can explain why?