Hi all. I'm trying to write multiple values to influx DB through a single node. What confuses me about the node-red-contrib-influxdb batch node is that I'm not sure where to specify the database I want to write to, so I'm trying a different method. Here is my example flow where I try to write multiple values to influx using a single output node:
[
{
"id": "e6665605.651228",
"type": "inject",
"z": "67579b26.28b6e4",
"name": "1 minute inject",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 320,
"y": 180,
"wires": [
[
"90085c22.e39ae"
]
]
},
{
"id": "90085c22.e39ae",
"type": "MSSQL",
"z": "67579b26.28b6e4",
"mssqlCN": "ee093d52.6f53a",
"name": "Read from myTable",
"query": "select top 1 DATEDIFF(s, '1970-01-01 00:00:00', timestamp) as t_date, tag1, tag2, tag3 from [server].database.[dbo].[table]\nwhere not (tag1 is null OR tag2 is null OR tag3 is null)\norder by timestamp desc",
"outField": "payload",
"x": 580,
"y": 180,
"wires": [
[
"5bbe5a5c.451874"
]
]
},
{
"id": "5bbe5a5c.451874",
"type": "function",
"z": "67579b26.28b6e4",
"name": "Prepare InfluxDB Writes",
"func": "time = (msg.payload[0].t_date-7200)*1000;\ntag1 = msg.payload[0].tag1;\ntag2 = msg.payload[0].tag2;\ntag3 = msg.payload[0].tag3;\n\nmsg.payload = [\n {\n measurement: \"my_tag1\",\n value: tag1\n },\n {\n measurement: \"my_tag2\",\n value: tag1\n },\n {\n measurement: \"my_tag3\",\n value: tag1\n },\n]\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 850,
"y": 180,
"wires": [
[
"53977f30.eea18"
]
]
},
{
"id": "53977f30.eea18",
"type": "split",
"z": "67579b26.28b6e4",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "payload",
"x": 1030,
"y": 380,
"wires": [
[
"c9f0a383.e9153",
"5f23740.255ad8c"
]
]
},
{
"id": "c9f0a383.e9153",
"type": "debug",
"z": "67579b26.28b6e4",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1290,
"y": 440,
"wires": []
},
{
"id": "5f23740.255ad8c",
"type": "influxdb out",
"z": "67579b26.28b6e4",
"influxdb": "",
"name": "",
"measurement": "",
"precision": "",
"retentionPolicy": "",
"database": "mydatabase",
"precisionV18FluxV20": "ms",
"retentionPolicyV18Flux": "",
"org": "organisation",
"bucket": "bucket",
"x": 1300,
"y": 380,
"wires": []
},
{
"id": "ee093d52.6f53a",
"type": "MSSQL-CN",
"tdsVersion": "7_4",
"name": "My Server",
"server": "address",
"port": "",
"encyption": false,
"database": "database",
"useUTC": true,
"connectTimeout": "15000",
"requestTimeout": "15000",
"cancelTimeout": "5000",
"pool": "5"
}
]
What I want to do, is to set the "measurement" parameter of the influx output node dynamically based on the value of "measurement" in my object that I'm splitting. So it should write all three of my tags to the influxDB database indvidually. Is that possible?