Error while sending data to influxDB

Hi,

Since I am new to node red and influxDB, I am trying to manipulate those 2 tech in order to be better with my own project.

I have created a simple flow which generate a random number (quiet simple), now that I have it, I'd like to send it my DB with influxDB.
I have created my database inside influxDB and I got this error

Error: A 400 Bad Request error occurred: {"error":"error parsing query: found stations, expected SELECT, DELETE, SHOW, CREATE, DROP, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1"}

Cannot figure out what is wrong...

Thank you for your help

Here is my flow :
[
{
"id": "8ad428d.bf355d8",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": ""
},
{
"id": "5dcbbf8a.37345",
"type": "inject",
"z": "8ad428d.bf355d8",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "3",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 190,
"y": 140,
"wires": [
[
"5df3b750.729b8"
]
]
},
{
"id": "5df3b750.729b8",
"type": "function",
"z": "8ad428d.bf355d8",
"name": "random number",
"func": "number = Math.random()\nmsg.payload = {\n value : number\n \n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 400,
"y": 220,
"wires": [
[
"d565010f.4d7a"
]
]
},
{
"id": "d565010f.4d7a",
"type": "influxdb in",
"z": "8ad428d.bf355d8",
"influxdb": "a5ced9d1.00dc1",
"name": "weather",
"query": "stations",
"rawOutput": false,
"precision": "",
"retentionPolicy": "",
"x": 640,
"y": 300,
"wires": [

]
},
{
"id": "a5ced9d1.00dc1",
"type": "influxdb",
"z": "8ad428d.bf355d8",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "ESSAI",
"name": "TEST",
"usetls": false,
"tls": ""
}
]

Welcome to the forum.
You need to format your code properly, see:

1 Like

error parsing query: found stations, expected SELECT

Your query:

"query": "stations",

Should be a select statement, or:

Your topic title "Error while sending data to influxDB" seems to suggest that you want to "insert" it into your database, then it should be a insert query.

Also note that the influxdb nodes have lots of information when you select the node. Additional documentation for the nodes.

1 Like

You have said the error is from writing data, but I suspect that it is the influx In node that is generating it. You can tell if you look carefully at the output in the debug window.
In that node you have to provide a valid query, which it appears you have not.

1 Like

thank you, reading your link helped me and I solved my problem !

thank you