HTTP Request Node returns "error parsing points" with data from "mqtt in" node

Hi all,
New to Node-RED here, I would like to ask for advice with the following situation
Context:
I have a sensor that is throwing data to a mqtt broker, then is sent to Grafana cloud for real time monitoring, and I need the data to go to prometheus (also cloud) to generate historical data.
Today the data flow is:
“IoT device” -> brokemqtt in ec2 -> Grafana in cloud account.
I am wanting to set it up as follows:
“IoT device” -> brokermqtt -> node-red -> Prometheus in cloud account.

I managed to integrate the broker with node-red but when I run a test I get the following error from the http node, noticed the debug node connected directly to mqtt states an object and the debug mode connected to http request states a string, but im not really sure which would be the correct format.

8/6/2024, 21:23:22node: debug 147
test : msg.payload : string[51]
"{"code":"invalid","message":"error parsing points"}"

This is the output of debug node connected directly to mqtt in node:

8/6/2024, 21:23:22node: debug 146
test : msg.payload : Object
{ motion: "1" }

Adding the export of the flow im using

[
    {
        "id": "4948190ab7e83e81",
        "type": "tab",
        "label": "Flow 6",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "27546ba373b3314f",
        "type": "http request",
        "z": "4948190ab7e83e81",
        "name": "",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "basic",
        "senderr": false,
        "headers": [],
        "x": 1250,
        "y": 340,
        "wires": [
            [
                "487e21f982c5bc2b"
            ]
        ]
    },
    {
        "id": "09385b9c1e9e223a",
        "type": "debug",
        "z": "4948190ab7e83e81",
        "name": "debug 2491",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1250,
        "y": 220,
        "wires": []
    },
    {
        "id": "af66a5dfdfe263b7",
        "type": "mqtt in",
        "z": "4948190ab7e83e81",
        "name": "",
        "topic": "test",
        "qos": "0",
        "datatype": "auto-detect",
        "broker": "d6bfc762efe92b49",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 250,
        "y": 260,
        "wires": [
            [
                "09385b9c1e9e223a",
                "27546ba373b3314f"
            ]
        ]
    },
    {
        "id": "487e21f982c5bc2b",
        "type": "debug",
        "z": "4948190ab7e83e81",
        "name": "debug 2492",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1510,
        "y": 340,
        "wires": []
    },
    {
        "id": "d6bfc762efe92b49",
        "type": "mqtt-broker",
        "name": "",
        "broker": "127.0.0.1",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

Any comments about this are welcome!
Regards.-

Change the http node to output a string and inspect the valu it outputs. You will see it is not recieving valid JSON in is response. You can verify that by pairing it into one of the many online JASN validator sites.

Hi Steve,

Thanks for the quick reply,
Im failing in know what type of parsing I need to apply in the output of the mqtt node I guess, but is not something I have experience with.

I tried checking the JSON format as you mentioned but I could not realize what kind of parsing im needing.

I have tried with a "string" and "change" node, and was able to the following:
With string node: was able to change the parameter to a number instead of string.
With change node: was able to change to change the value to a number as well, as shown in the screenshot:

image

But when I check the http node I have the same error for all the nodes:

{ code: "invalid", message: "error parsing points" }

This is the flow where I ran the tests mentioned.

[{"id":"76386ecab71ad799","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"8a4adf449ce79d58","type":"http request","z":"76386ecab71ad799","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://influx-prod-13-prod-us-east-0.grafana.net/api/v1/push/influx/write","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"x":1290,"y":280,"wires":[["01dfc840e4ad4671"]]},{"id":"2c8ad8ab20b22332","type":"debug","z":"76386ecab71ad799","name":"String node output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1550,"y":220,"wires":[]},{"id":"e3af1cd999478567","type":"mqtt in","z":"76386ecab71ad799","name":"","topic":"dt/theia-pro/ESP32-70041DAE42C4/temperature","qos":"0","datatype":"auto-detect","broker":"d6bfc762efe92b49","nl":false,"rap":true,"rh":0,"inputs":0,"x":480,"y":220,"wires":[["b35038ae7b404edd","17bbb61d6f2b972d","d16075ed54bdcf81"]]},{"id":"b35038ae7b404edd","type":"change","z":"76386ecab71ad799","name":"","rules":[{"t":"set","p":"payload.temperature","pt":"msg","to":"$number(payload.temperature)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":280,"wires":[["8a4adf449ce79d58"]]},{"id":"01dfc840e4ad4671","type":"debug","z":"76386ecab71ad799","name":"Change node output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1540,"y":280,"wires":[]},{"id":"17bbb61d6f2b972d","type":"string","z":"76386ecab71ad799","name":"","methods":[{"name":"setValue","params":[{"type":"msg","value":"payload.temperature"}]},{"name":"toFloat","params":[{"type":"msg","value":"payload.temperature"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1030,"y":220,"wires":[["91ad5f1b716407a7"]]},{"id":"62f637f4b67ee046","type":"debug","z":"76386ecab71ad799","name":"Raw Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1510,"y":120,"wires":[]},{"id":"91ad5f1b716407a7","type":"http request","z":"76386ecab71ad799","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://influx-prod-13-prod-us-east-0.grafana.net/api/v1/push/influx/write","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"x":1290,"y":220,"wires":[["2c8ad8ab20b22332"]]},{"id":"d16075ed54bdcf81","type":"http request","z":"76386ecab71ad799","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://influx-prod-13-prod-us-east-0.grafana.net/api/v1/push/influx/write","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"x":1290,"y":120,"wires":[["62f637f4b67ee046"]]},{"id":"d6bfc762efe92b49","type":"mqtt-broker","name":"","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

It looks like you are trying to POST data to an endpoint of /api/v1/push/influx/write

You have attached an MQTT directly to the HTTP Request node. I highly doubt the format of data coming out of MQTT is the correct format for that endpoint.

From your screenshot, your MQTT data is an object { temperature: "value" }

How is it supposed to formatted for that end point? Can you tell us or link us to the documentation?

If you want to drive influxdb directly using http requests then you will need to study the influxdb docs to see what you need to do. Alternatively use node-red-contrib-influxdb to do the interface for you. With the output node from there you would be able to send your mqtt data directly to influx.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.