Is there a way to write to QuestDB with Node-Red?

Hi,

i have installed latest QuestDB 8.3.3 on my Raspberry Pi with Node-Red. Is there a way to write Data over Node-Red to QuestDB ?

I know it works over Node.js but Node-Red is more comfortable and i have more Visual Feedback.

We are a drop in replacement for Influx, protocol wise, so you can generally use the same connectors.

Maybe try to follow a guide for Influx v1/v2 connections?

I have tried v1 InfluxDB Node and v1.8 Flux.

For the v1 InfluxDB connection Node i get Error 404 “Not Found Error”

For the v1.8 InfluxDB i get Error 401 Unauthorized.

In both Nodes i have the correct Server, Port, User and Password.

Hey, can you share what settings you use? Perhaps some screenshots?

Usually, it just needs a configuration tweak. For example, bucket should be qdb, and the target port should be 9000 for HTTP, or 9009 for TCP.

Hi,
yeah sure here are the Screenshots from the InfluxDB IN Node Connection Settings. InfluxDB Ver.2.0 requires a token not a User / Password Setting.

Heres the Second Screenshot because i can post only 1 as new User.

Ok this package works for me: node-red-contrib-influxdb (node) - Node-RED

You must use the out node.

I used this configuration:

The credentials are default admin:quest, no TLS.

This is my flow:

[
    {
        "id": "9c52a5933925018f",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "17bd4566.e842bb",
        "type": "influxdb out",
        "z": "9c52a5933925018f",
        "influxdb": "eeb221fb.ab27f",
        "name": "",
        "measurement": "test",
        "precision": "",
        "retentionPolicy": "",
        "database": "",
        "retentionPolicyV18Flux": "",
        "org": "",
        "bucket": "",
        "x": 580,
        "y": 320,
        "wires": []
    },
    {
        "id": "be93bfeb.416c4",
        "type": "function",
        "z": "9c52a5933925018f",
        "name": "single value",
        "func": "msg.payload = Math.random()*10;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 410,
        "y": 320,
        "wires": [
            [
                "17bd4566.e842bb"
            ]
        ]
    },
    {
        "id": "31f9f174.ce060e",
        "type": "inject",
        "z": "9c52a5933925018f",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 260,
        "y": 320,
        "wires": [
            [
                "be93bfeb.416c4"
            ]
        ]
    },
    {
        "id": "eeb221fb.ab27f",
        "type": "influxdb",
        "hostname": "localhost",
        "port": "9000",
        "protocol": "http",
        "database": "qdb",
        "name": "test",
        "usetls": false,
        "tls": "d50d0c9f.31e858",
        "influxdbVersion": "1.x",
        "url": "http://localhost:8086",
        "timeout": "",
        "rejectUnauthorized": true
    },
    {
        "id": "d50d0c9f.31e858",
        "type": "tls-config",
        "name": "",
        "cert": "",
        "key": "",
        "ca": "",
        "certname": "",
        "keyname": "",
        "caname": "",
        "servername": "",
        "verifyservercert": false,
        "alpnprotocol": ""
    }
]

Then simply deploy and click the button to send a message, and see it appear in QuestDB.

You cannot query via the in node of course, we have different query languages.

For querying, you will need to choose one of the Postgres connectors.

Honestly though, this seems much harder than just using the Node libraries directly, so I would invst more time in going that route if I were you!

Hmm ok,

i get 401 Unauthorized Error, i have Set Username = admin and Password in the server.conf of QuestDB and i can Login with this over the HTTP Interface Port 9000

I used the OUT Node from InfluxDB v.1

Any things to configure in the Server.conf to work with this ?

I used the default config. There are several password options, how have you set them?

What have you changed in your config?

I have only changed Username and Password for http Authentication.

Now it works dont know why but it works :grinning_face:

Magic i have changed nothing

Another additional Question, where can i change the default Database name ? I cant find a Parameter in Server.conf

You can just click on the button!

image

It works fine without Authentication, if i set my own Password → Server.conf http.password http.user i get 401 Error Authentication failed from InfluxDB Out Node.

Is there another Password to set in Server.conf ? e.g. Postgre Password ?

No, HTTP is enough, but you need to restart the database after you change the settings, so that it can pick up the new credentials.

Yes, I did that. I also restarted QuestDB. Accessing QuestDB from the browser with a username/password works. Unfortunately, it doesn’t work in Node-Red, where I get a 401 Authentication Error.

Heres Node-Red Json its the same as yours. User: admin Password: quest

[
    {
        "id": "847873c2e28f2e0b",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8904fed808f8eb71",
        "type": "influxdb out",
        "z": "847873c2e28f2e0b",
        "influxdb": "d9be43fee262a1f8",
        "name": "",
        "measurement": "test",
        "precision": "",
        "retentionPolicy": "",
        "database": "",
        "retentionPolicyV18Flux": "",
        "org": "",
        "bucket": "",
        "x": 580,
        "y": 320,
        "wires": []
    },
    {
        "id": "68fb01f694c7489d",
        "type": "function",
        "z": "847873c2e28f2e0b",
        "name": "single value",
        "func": "msg.payload = Math.random()*10;\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 410,
        "y": 320,
        "wires": [
            [
                "8904fed808f8eb71"
            ]
        ]
    },
    {
        "id": "1c302e4008f240d5",
        "type": "inject",
        "z": "847873c2e28f2e0b",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 260,
        "y": 320,
        "wires": [
            [
                "68fb01f694c7489d"
            ]
        ]
    },
    {
        "id": "d9be43fee262a1f8",
        "type": "influxdb",
        "hostname": "localhost",
        "port": "9000",
        "protocol": "http",
        "database": "qdb",
        "name": "test",
        "usetls": false,
        "tls": "d50d0c9f.31e858",
        "influxdbVersion": "1.x",
        "url": "http://localhost:8086",
        "timeout": "",
        "rejectUnauthorized": true
    },
    {
        "id": "d50d0c9f.31e858",
        "type": "tls-config",
        "name": "",
        "cert": "",
        "key": "",
        "ca": "",
        "certname": "",
        "keyname": "",
        "caname": "",
        "servername": "",
        "verifyservercert": false
    }
]

Heres the Server.conf only the First Part because i cant post the whole thing, the Rest is 100% Standard nothing changed:

# Comment or set to false to allow QuestDB to start even in the presence of config errors.
config.validation.strict=true

# number of worker threads shared across the application. Increasing this number will increase parallelism in the application at the expense of CPU resources
#shared.worker.count=2

# comma-delimited list of CPU ids, one per thread specified in "shared.worker.count". By default, threads have no CPU affinity
#shared.worker.affinity=

# toggle whether worker should stop on error
#shared.worker.haltOnError=false

# RAM usage limit, as a percentage of total system RAM. A zero value does not
# set any limit. The default is 90.
#ram.usage.limit.percent=90

# RAM usage limit, in bytes. A zero value (the default) does not set any limit.
# If both this and ram.usage.limit.percent are non-zero, the lower limit takes precedence.
#ram.usage.limit.bytes=0

# Repeats compatible migrations from the specified version. The default setting of 426 allows to upgrade and downgrade QuestDB in the range of versions from 6.2.0 to 7.0.2.
# If set to -1 start time improves but downgrades to versions below 7.0.2 and subsequent upgrades can lead to data corruption and crashes.
#cairo.repeat.migration.from.version=426

################ HTTP settings ##################

# enable HTTP server
#http.enabled=true

# IP address and port of HTTP server
#http.net.bind.to=127.0.0.1:9000

# Uncomment to enable HTTP Basic authentication
http.user=admin
http.password=quest

#http.net.connection.limit=256
# Windows OS might have a limit on TCP backlog size. Typically Windows 10 has max of 200. This
# means that even if net.connection.limit is set over 200 it wont be possible to have this many
# concurrent connections. To overcome this limitation Windows has an unreliable hack, which you can
# exercise with this flag. Do only set it if you actively try to overcome limit you have already
# experienced. Read more about SOMAXCONN_HINT here https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen
#http.net.connection.hint=false

# Idle HTTP connection timeout in milliseconds.
#http.net.connection.timeout=5m

and so on ....

For whatever reason, the database doesn’t seem to receive the Authorization header from node-red. Let me look into it a bit.

Okay, it’s quite straightforward. That connector sends the username and password as parameters in the query string:

E@@#($
'qi%%POST /write?db=qdb&p=quest&precision=n&rp=&u=admin HTTP/1.1
content-length: 28
Host: localhost:9000
Connection: keep-alive

test value=7.650132747158053

Instead, QuestDB expects to receive an Authorization: Basic header. Influx also supports this header, but this node-red component does not use it.

Unfortunately, you will need to find an alternative that uses the header authentication method.

Or swap to regular Node.js!

Thank you for the effort.

I try to send it with the Header.