Post JSON object to InfluxDB

Hi, everyone I try to post the JSON data into influx but when I post it database by http://localhost:8086/write?db=weathermap it doesn't work. How can I fix this issue

[
    {
        "id": "82c273f1293e06ae",
        "type": "tab",
        "label": "Flow 6",
        "disabled": false,
        "info": ""
    },
    {
        "id": "ca3dd8686bec984b",
        "type": "http request",
        "z": "82c273f1293e06ae",
        "name": "http GET",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "credentials": {},
        "x": 140,
        "y": 300,
        "wires": [
            [
                "0372ae89187ebc26"
            ]
        ]
    },
    {
        "id": "c40f27e9377b4b66",
        "type": "debug",
        "z": "82c273f1293e06ae",
        "name": "LogPosttoDB",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 180,
        "wires": []
    },
    {
        "id": "bd51bb60b3fd81e4",
        "type": "inject",
        "z": "82c273f1293e06ae",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 110,
        "y": 200,
        "wires": [
            [
                "ca3dd8686bec984b"
            ]
        ]
    },
    {
        "id": "b63dea331e7a0a70",
        "type": "http request",
        "z": "82c273f1293e06ae",
        "name": "http POST",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://localhost:8086/write?db=weathermap",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "credentials": {
            "user": "",
            "password": ""
        },
        "x": 450,
        "y": 240,
        "wires": [
            [
                "c40f27e9377b4b66"
            ]
        ]
    },
    {
        "id": "cc94f94035038243",
        "type": "debug",
        "z": "82c273f1293e06ae",
        "name": "LogJSON",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 400,
        "wires": []
    },
    {
        "id": "0372ae89187ebc26",
        "type": "json",
        "z": "82c273f1293e06ae",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": true,
        "x": 310,
        "y": 300,
        "wires": [
            [
                "cc94f94035038243",
                "b63dea331e7a0a70"
            ]
        ]
    }
]

Welcome to the forum @nisitpuk.

Is there a reason that you are not using the influxdb nodes? node-red-contrib-influxdb (node) - Node-RED
They work well and are well maintained.

1 Like

many thanks for a fast reply, @Colin I follow you in many topics. So I will be studying your suggestion and feedback you soon.

Again, Thank you @Colin for your suggestion. I can do it after I learn on this link [node-red-contrib-influxdb "node-red-contrib-influxdb (node) - Node-RED" it is very useful for me. Now I can post the JSON data get from OpenWeather Map API and post to influxDB. The latest flow is shown below.

[{"id":"82c273f1293e06ae","type":"tab","label":"Flow 6","disabled":false,"info":""},{"id":"ca3dd8686bec984b","type":"http request","z":"82c273f1293e06ae","name":"http GET","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://api.openweathermap.org/data/2.5/weather?q=Tambon Rangsit&appid=2275b2c49293037fed692057360e0a0a","tls":"","persist":false,"proxy":"","authType":"","x":140,"y":160,"wires":[["0372ae89187ebc26"]]},{"id":"c40f27e9377b4b66","type":"debug","z":"82c273f1293e06ae","name":"LogPosttoDB","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":380,"wires":[]},{"id":"bd51bb60b3fd81e4","type":"inject","z":"82c273f1293e06ae","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":150,"y":80,"wires":[["ca3dd8686bec984b"]]},{"id":"cc94f94035038243","type":"debug","z":"82c273f1293e06ae","name":"LogJSON","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":300,"y":240,"wires":[]},{"id":"0372ae89187ebc26","type":"json","z":"82c273f1293e06ae","name":"","property":"payload","action":"","pretty":true,"x":130,"y":240,"wires":[["40e3da509c4b5071","cc94f94035038243"]]},{"id":"40e3da509c4b5071","type":"function","z":"82c273f1293e06ae","name":"multiple measurement points","func":"msg.payload = [\n    {\n        measurement: \"location\",\n        fields: {\n            longtitude: msg.payload.coord.lon,\n            latitude: msg.payload.coord.lat\n        },\n        tags:{\n            type:\"location\"\n        },\n    },\n    {\n        measurement: \"weather\",\n        fields: {\n            temp: msg.payload.main.temp,\n            temp_min: msg.payload.main.temp_min,\n            temp_max: msg.payload.main.temp_max,\n            pressure: msg.payload.main.pressure,\n            humidity: msg.payload.main.humidity,\n            sea_level: msg.payload.main.sea_level,\n            grnd_level: msg.payload.main.grnd_level\n        },\n        tags:{\n            type:\"weather\"\n        },\n    },\n    {\n        measurement: \"wind\",\n        fields: {\n            speed: msg.payload.wind.speed,\n            deg: msg.payload.wind.deg,\n            gust: msg.payload.wind.gust,\n        },\n        tags:{\n            type:\"wind\"\n        },\n    },\n    {\n        measurement: \"rain\",\n        fields: {\n            Onehour: msg.payload.rain[\"1h\"]\n        },\n        tags:{\n            type:\"rain\"\n        },\n    },\n    {\n        measurement: \"clouds\",\n        fields: {\n            all: msg.payload.clouds.all\n        },\n        tags:{\n            type:\"rain\"\n        },\n    },\n    \n]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":320,"wires":[["c40f27e9377b4b66","d57e179a6de9bf6e"]]},{"id":"d57e179a6de9bf6e","type":"influxdb batch","z":"82c273f1293e06ae","influxdb":"6ca8bde.9eb2f44","precision":"","retentionPolicy":"","name":"","database":"weatherstation","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"","bucket":"","x":540,"y":320,"wires":[]},{"id":"6ca8bde.9eb2f44","type":"influxdb","hostname":"localhost","port":"8086","protocol":"https","database":"new_db","name":"DBweatherstation","usetls":true,"tls":"f7f39f4e.896ae","influxdbVersion":"1.8-flux","url":"http://localhost:8086","rejectUnauthorized":false},{"id":"f7f39f4e.896ae","type":"tls-config","name":"local-tls","cert":"","key":"","ca":"","certname"![Flow|690x317](upload://tITnwNurdFhNEUEJz6VGQA9UOwj.png)
![payload|671x500](upload://gBg8tr01GpHdshtPlUElTqzExPk.png)
:"","keyname":"","caname":"","verifyservercert":false}]


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