# How to collect information from multiple sources and have them seperately analyzed

**URL:** <https://discourse.nodered.org/t/how-to-collect-information-from-multiple-sources-and-have-them-seperately-analyzed/52938>\
**Category:** General\
**Created:** [29 October 2021 12:07 UTC](https://discourse.nodered.org/t/how-to-collect-information-from-multiple-sources-and-have-them-seperately-analyzed/52938 "2021-10-29T12:07:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)\
**Post date:** [29 October 2021 12:07 UTC](https://discourse.nodered.org/t/how-to-collect-information-from-multiple-sources-and-have-them-seperately-analyzed/52938/1 "2021-10-29T12:07:39Z")

</div>

My goal is to collect health information of different servers and have them put into MQTT-topics.

As I don't like to copy the flows for each server (I'm collecting the exact same data, but from multiple sources), I come from a list of servers and like to push them into seperate MQTT-topics, which I then can monitor and take necessary action if e.g. one server runs into problems.

So, basically I do the following:

```auto
global.set("hostname", "openhabmain");
global.set("hostip", "192.168.xx.xx");
global.set("metricsurl", "http://192.168.xx.xx:8080/rest/metrics/prometheus")

msg.url = global.get("metricsurl");
msg.payload = global.get("hostip");
node.send(msg);

global.set("hostname", "openhabutilities");
global.set("hostip", "192.168.xx.xx");
global.set("metricsurl", "http://192.168.xx.xx:8080/rest/metrics/prometheus")

msg.url = global.get("metricsurl");
msg.payload = global.get("hostip");
node.send(msg);

```

later on, if a got my response I send them to different mqtt-topics:

```auto
    msg1.payload = Object.assign(msg.payload[key]);
    msg1.topic = "openHAB/master/snmp/" + global.get("hostname") + "/" + key;
    node.send(msg1)

```

But as soon as I inject the flow, the "global variable" gets overwritten and I basically get only one set of information. So what is the best practise here, to have flow specific variables?

if it helps, here a screenshot and the flow:  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/908da5a0de8e1fc259f002d6b6908ed9c062f43f.png)

> **Flow**
>
> ```auto
> [
> {
> "id": "eb920791.e124e8",
> "type": "inject",
> "z": "84ed84b2.83431",
> "name": "",
> "props": [
> {
> "p": "payload"
> },
> {
> "p": "topic",
> "vt": "str"
> }
> ],
> "repeat": "300",
> "crontab": "",
> "once": false,
> "onceDelay": "",
> "topic": "",
> "payload": "",
> "payloadType": "date",
> "x": 230,
> "y": 600,
> "wires": [
> [
> "de4a1af6.4ae9b"
> ]
> ]
> },
> {
> "id": "71173d2a.39309c",
> "type": "http request",
> "z": "84ed84b2.83431",
> "name": "getOpenhabMetrics",
> "method": "GET",
> "ret": "txt",
> "paytoqs": "body",
> "url": "",
> "tls": "",
> "persist": false,
> "proxy": "",
> "authType": "",
> "x": 370,
> "y": 720,
> "wires": [
> [
> "344c1065.04ad48"
> ]
> ]
> },
> {
> "id": "344c1065.04ad48",
> "type": "function",
> "z": "84ed84b2.83431",
> "name": "Metrics2JSON",
> "func": "var lines = msg.payload.split(\"\\n\");\n\nvar json = \"{\";\nvar json_object = {};\n\nfor(var i = 0;i < lines.length;i++){\n // ist es eine Kommentar-Zeile?\n if (!lines[i].startsWith(\"#\")) {\n // ist es eine kurze \"Leerzeile\"?\n lines[i] = lines[i];\n if (lines[i].length > 5) {\n var data_tmp1 = lines[i].split(\"{\");\n var data_name = data_tmp1[0]; // Datenbezeichnung \n var data_tmp2 = data_tmp1[1].split(\"}\");\n var data_value = data_tmp2[1].replace(\" \", \"\"); // Datenwert\n var data_meta = data_tmp2[0]; // Daten-Meta\n \n data_meta = data_meta.replace(/=/g, '\": ');\n data_meta = data_meta.replace(/,/g, ',\"');\n if(data_name in json_object == false){\n json_object[data_name] = {};\n }\n \n var data_injson = true;\n var data_distinquisher = \"\";\n // json zusammensetzen\n switch(true){\n case data_name == \"jvm_threads_daemon_threads\":\n data_distinquisher = \"\";\n break;\n case data_name == \"jvm_buffer_count_buffers\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"jvm_threads_states_threads\":\n data_distinquisher = \",state\";\n break;\n case data_name == \"jvm_memory_max_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"executor_queued_tasks\":\n data_distinquisher = \"pool\";\n break;\n case data_name == \"executor_pool_core_threads\":\n data_distinquisher = \"pool\";\n break;\n case data_name == \"event_count_total\":\n data_injson = false;\n break;\n case data_name == \"executor_pool_core_threads\":\n data_distinquisher = \"pool\";\n break;\n case data_name == \"jvm_buffer_total_capacity_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"jvm_memory_used_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"openhab_rule_runs_total\":\n data_injson = false;\n break;\n case data_name == \"executor_pool_size_threads\":\n data_injson = false;\n break;\n case data_name == \"jvm_buffer_memory_used_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"executor_active_threads\":\n data_injson = false;\n break;\n case data_name == \"jvm_memory_committed_bytes\":\n data_injson = false;\n break;\n case data_name == \"executor_completed_tasks_total\":\n data_injson = false;\n break;\n case data_name == \"openhab_bundle_state\":\n data_injson = false;\n break;\n case data_name == \"executor_pool_max_threads\":\n data_injson = false;\n break;\n case data_name == \"jvm_gc_pause_seconds_count\":\n data_injson = false;\n break;\n case data_name == \"jvm_gc_pause_seconds_sum\":\n data_injson = false;\n break;\n case data_name == \"jvm_gc_pause_seconds_max\":\n data_injson = false;\n break;\n case data_name == \"openhab_thing_state\":\n data_distinquisher = \"thing\";\n break;\n case data_name == \"executor_queue_remaining_tasks\":\n data_injson = false;\n break;\n default:\n data_distinquisher = \"\";\n }\n \n if (data_injson == true){\n if (data_distinquisher != \"\") {\n var data_att_tmp1 = lines[i].split(data_distinquisher);\n var data_att_tmp2 = data_att_tmp1[1].split(',');\n data_name_sub = data_att_tmp2[0].replace('=\"', '');\n data_name_sub = data_name_sub.replace('\"', '');\n // json_object[data_name].push(data_name_sub);\n json_object[data_name][data_name_sub] = data_value;\n }\n if (data_distinquisher == \"\") {\n data_name_sub = \"value\";\n // json_object[data_name].push(data_name_sub);\n json_object[data_name][data_name_sub] = data_value;\n }\n\n json += '\"' + data_name + '\": {';\n json += '\"' + data_meta;\n json += 'value\": \"' + data_value + '\"},';\n }\n }\n }\n}\njson += '\"timestamp\": 123}';\n\n/*\nmsg.payload = data_name; // executor_queue_remaining_tasks\nnode.send(msg);\nmsg.payload = data_value; // 2.147483647E9\nnode.send(msg);\nmsg.payload = data_meta; // metric=\"openhab.core.metric.threadpools\",name=\"lsp\",openhab_core_metric=\"true\",pool=\"lsp\",\nnode.send(msg);\n*/\n\nmsg.payload = JSON.stringify(json_object);\nreturn msg;\n\n\n// executor_queue_remaining_tasks{metric=\"openhab.core.metric.threadpools\",name=\"lsp\",openhab_core_metric=\"true\",pool=\"lsp\",} 2.147483647E9\n",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "x": 320,
> "y": 840,
> "wires": [
> [
> "543607f4.df7328",
> "ce6de5b9.c96a7"
> ]
> ]
> },
> {
> "id": "543607f4.df7328",
> "type": "json",
> "z": "84ed84b2.83431",
> "name": "JSON2JSObject",
> "property": "payload",
> "action": "obj",
> "pretty": true,
> "x": 320,
> "y": 940,
> "wires": [
> [
> "a65939ae.ad9d88"
> ]
> ]
> },
> {
> "id": "9aa67c3f.8ef998",
> "type": "mqtt out",
> "z": "84ed84b2.83431",
> "name": "",
> "topic": "",
> "qos": "1",
> "retain": "true",
> "broker": "4672ca10.309984",
> "x": 730,
> "y": 1060,
> "wires": []
> },
> {
> "id": "a65939ae.ad9d88",
> "type": "function",
> "z": "84ed84b2.83431",
> "name": "Object2MQTT",
> "func": "for (let key in msg.payload){\n let msg1 = {payload:{}};\n // msg1.payload[key] = Object.assign(msg.payload[key],{\"key\":key});\n msg1.payload = Object.assign(msg.payload[key]);\n msg1.topic = \"openHAB/master/snmp/\" + global.get(\"hostname\") + \"/\" + key;\n node.send(msg1)\n}\nreturn;",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "x": 520,
> "y": 940,
> "wires": [
> [
> "9b49727.034581",
> "462efda4.e53c84"
> ]
> ]
> },
> {
> "id": "9b49727.034581",
> "type": "debug",
> "z": "84ed84b2.83431",
> "name": "",
> "active": false,
> "tosidebar": true,
> "console": false,
> "tostatus": false,
> "complete": "false",
> "statusVal": "",
> "statusType": "auto",
> "x": 750,
> "y": 940,
> "wires": []
> },
> {
> "id": "ce6de5b9.c96a7",
> "type": "debug",
> "z": "84ed84b2.83431",
> "name": "",
> "active": false,
> "tosidebar": true,
> "console": false,
> "tostatus": false,
> "complete": "false",
> "statusVal": "",
> "statusType": "auto",
> "x": 550,
> "y": 880,
> "wires": []
> },
> {
> "id": "462efda4.e53c84",
> "type": "rbe",
> "z": "84ed84b2.83431",
> "name": "only changes",
> "func": "rbe",
> "gap": "",
> "start": "",
> "inout": "out",
> "property": "payload",
> "x": 590,
> "y": 1060,
> "wires": [
> [
> "9aa67c3f.8ef998"
> ]
> ]
> },
> {
> "id": "de4a1af6.4ae9b",
> "type": "function",
> "z": "84ed84b2.83431",
> "name": "openHAB-Metrics",
> "func": "/*\nglobal.set(\"hostname\", \"nodered\");\nglobal.set(\"hostip\", \"192.168.xx.xx\");\n\nmsg.payload = global.get(\"hostip\");\nnode.send(msg);\n*/\n\nglobal.set(\"hostname\", \"openhabmain\");\nglobal.set(\"hostip\", \"192.168.xx.xx\");\nglobal.set(\"metricsurl\", \"http://192.168.xx.xx:8080/rest/metrics/prometheus\")\n\nmsg.url = global.get(\"metricsurl\");\nmsg.payload = global.get(\"hostip\");\nnode.send(msg);\n\nglobal.set(\"hostname\", \"openhabutilities\");\nglobal.set(\"hostip\", \"192.168.xx.xx\");\nglobal.set(\"metricsurl\", \"http://192.168.xx.xx:8080/rest/metrics/prometheus\")\n\nmsg.url = global.get(\"metricsurl\");\nmsg.payload = global.get(\"hostip\");\nnode.send(msg);",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "x": 290,
> "y": 660,
> "wires": [
> [
> "71173d2a.39309c"
> ]
> ]
> },
> {
> "id": "4672ca10.309984",
> "type": "mqtt-broker",
> "name": "Synology",
> "broker": "192.168.xx.xx",
> "port": "1883",
> "clientid": "nodered",
> "usetls": false,
> "compatmode": false,
> "keepalive": "60",
> "cleansession": true,
> "birthTopic": "openHAB/master/nodered",
> "birthQos": "2",
> "birthRetain": "true",
> "birthPayload": "ON",
> "closeTopic": "openHAB/master/nodered",
> "closeQos": "2",
> "closeRetain": "true",
> "closePayload": "OFF",
> "willTopic": "openHAB/master/nodered",
> "willQos": "2",
> "willRetain": "true",
> "willPayload": "OFF"
> }
> ]
> 
> ```

Thanks!

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [29 October 2021 12:29 UTC](https://discourse.nodered.org/t/how-to-collect-information-from-multiple-sources-and-have-them-seperately-analyzed/52938/2 "2021-10-29T12:29:06Z")

</div>

As you have found out, global variables are not the way to go, especially when you want to reuse a flow but with different parameters (i.e. which server to connect to, and which topic to use).

The approach I like to use is to inject an array of objects, each with the parameterized data that is needed inside the main flow. So for your use case, maybe something like this in an `inject` node:

```auto
[
  {
    "hostname": "openhabmain",
    "hostip": "192.168.xx.xx",
    "metricsurl": "http://192.168.xx.xx:8080/rest/metrics/prometheus"
  },
  {
    "hostname": "openhabutilities",
    "hostip": "192.168.yy.yy",
    "metricsurl": "http://192.168.yy.yy:8080/rest/metrics/prometheus"
  }
]

```

Then use a `split` node wired into your main flow (I like to use `link` nodes here, but the new `link call` is ideal for this case). When your main info gathering flow is completed, the outputs are sent to a `join` node, that assembles all your data back into an array with the same size and order as your original list of servers. This makes it nice and easy to compare data across servers, and to aggregate the data for analysis or storing in a database.

Sorry, no time to put together an example flow to demonstrate the concept - but I'm hoping this will spark some ideas. If you are still stuck, I can see about doing that this weekend.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 October 2021 12:31 UTC](https://discourse.nodered.org/t/how-to-collect-information-from-multiple-sources-and-have-them-seperately-analyzed/52938/3 "2021-10-29T12:31:47Z")

</div>

```auto
global.set("hosts.openhabmain", 
    {"hostname": "openhabmain", 
    "hostip":"192.168.xx.xx", 
    "metricsurl": "http://192.168.xx.xx:8080/rest/metrics/prometheus"
})
let obj = global.get("hosts.openhabmain");
msg.url = obj.metricsurl;
msg.payload = obj.hostip;
node.send(msg);

```

I would store each source in its own object property, something like above.  
then retrieve as below

```auto
msg1.payload = Object.assign(msg.payload[key]);
    msg1.topic = "openHAB/master/snmp/" + global.get("hosts.openhubmain.hostname") + "/" + key;
    node.send(msg1)

```

---

<div class="post-metadata">

**Author:** ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)\
**Post date:** [29 October 2021 13:59 UTC](https://discourse.nodered.org/t/how-to-collect-information-from-multiple-sources-and-have-them-seperately-analyzed/52938/4 "2021-10-29T13:59:57Z")

</div>

You don't have to do all the heavy work for me! 😉

So I did the following:

1. configured the first function node with multiple outputs
2. included my desired configration (hostname, hostip, metricsurl) in objects
3. returned the objects seperately in each one of the outputs
4. started the flows with outputs

looks like this:

```auto
var msg1 = {payload:{
    "hostname": "openhabmain",
    "hostip": "192.168.xx.xx",
    "metricsurl": "http://192.168.xx.xx:8080/rest/metrics/prometheus"
  }};

var msg2 = {payload:{
    "hostname": "openhabutilities",
    "hostip": "192.168.yy.yy",
    "metricsurl": "http://192.168.yy.yy:8080/rest/metrics/prometheus"
  }};

return [msg1, msg2];

```

then

```auto
msg.host = msg.payload.hostip;
msg.url = msg.payload.metricsurl;
msg.hostname = msg.payload.hostname;

msg.payload = "";
return msg;

```

So I can re-use the `msg.hostname` later on, when I use that variable as part of the mqtt-topic:

```auto
    msg1.topic = "openHAB/master/snmp/" + msg.hostname + "/" + key;

```

for anyone interested here screenshot and flow again:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/9534d6008c5813e1c681fe6b55c987b8caa538cc.png)

> **Summary**
>
> ```auto
> [
> {
> "id": "eb920791.e124e8",
> "type": "inject",
> "z": "84ed84b2.83431",
> "name": "",
> "props": [
> {
> "p": "payload"
> },
> {
> "p": "topic",
> "vt": "str"
> }
> ],
> "repeat": "300",
> "crontab": "",
> "once": false,
> "onceDelay": "",
> "topic": "",
> "payload": "",
> "payloadType": "date",
> "x": 150,
> "y": 580,
> "wires": [
> [
> "de4a1af6.4ae9b"
> ]
> ]
> },
> {
> "id": "71173d2a.39309c",
> "type": "http request",
> "z": "84ed84b2.83431",
> "name": "getOpenhabMetrics",
> "method": "GET",
> "ret": "txt",
> "paytoqs": "body",
> "url": "",
> "tls": "",
> "persist": false,
> "proxy": "",
> "authType": "",
> "x": 710,
> "y": 640,
> "wires": [
> [
> "344c1065.04ad48"
> ]
> ]
> },
> {
> "id": "344c1065.04ad48",
> "type": "function",
> "z": "84ed84b2.83431",
> "name": "Metrics2JSON",
> "func": "var lines = msg.payload.split(\"\\n\");\n\nvar json = \"{\";\nvar json_object = {};\n\nfor(var i = 0;i < lines.length;i++){\n // ist es eine Kommentar-Zeile?\n if (!lines[i].startsWith(\"#\")) {\n // ist es eine kurze \"Leerzeile\"?\n lines[i] = lines[i];\n if (lines[i].length > 5) {\n var data_tmp1 = lines[i].split(\"{\");\n var data_name = data_tmp1[0]; // Datenbezeichnung \n var data_tmp2 = data_tmp1[1].split(\"}\");\n var data_value = data_tmp2[1].replace(\" \", \"\"); // Datenwert\n var data_meta = data_tmp2[0]; // Daten-Meta\n \n data_meta = data_meta.replace(/=/g, '\": ');\n data_meta = data_meta.replace(/,/g, ',\"');\n if(data_name in json_object == false){\n json_object[data_name] = {};\n }\n \n var data_injson = true;\n var data_distinquisher = \"\";\n // json zusammensetzen\n switch(true){\n case data_name == \"jvm_threads_daemon_threads\":\n data_distinquisher = \"\";\n break;\n case data_name == \"jvm_buffer_count_buffers\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"jvm_threads_states_threads\":\n data_distinquisher = \",state\";\n break;\n case data_name == \"jvm_memory_max_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"executor_queued_tasks\":\n data_distinquisher = \"pool\";\n break;\n case data_name == \"executor_pool_core_threads\":\n data_distinquisher = \"pool\";\n break;\n case data_name == \"event_count_total\":\n data_injson = false;\n break;\n case data_name == \"executor_pool_core_threads\":\n data_distinquisher = \"pool\";\n break;\n case data_name == \"jvm_buffer_total_capacity_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"jvm_memory_used_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"openhab_rule_runs_total\":\n data_injson = false;\n break;\n case data_name == \"executor_pool_size_threads\":\n data_injson = false;\n break;\n case data_name == \"jvm_buffer_memory_used_bytes\":\n data_distinquisher = \"id\";\n break;\n case data_name == \"executor_active_threads\":\n data_injson = false;\n break;\n case data_name == \"jvm_memory_committed_bytes\":\n data_injson = false;\n break;\n case data_name == \"executor_completed_tasks_total\":\n data_injson = false;\n break;\n case data_name == \"openhab_bundle_state\":\n data_injson = false;\n break;\n case data_name == \"executor_pool_max_threads\":\n data_injson = false;\n break;\n case data_name == \"jvm_gc_pause_seconds_count\":\n data_injson = false;\n break;\n case data_name == \"jvm_gc_pause_seconds_sum\":\n data_injson = false;\n break;\n case data_name == \"jvm_gc_pause_seconds_max\":\n data_injson = false;\n break;\n case data_name == \"openhab_thing_state\":\n data_distinquisher = \"thing\";\n break;\n case data_name == \"executor_queue_remaining_tasks\":\n data_injson = false;\n break;\n default:\n data_distinquisher = \"\";\n }\n \n if (data_injson == true){\n if (data_distinquisher != \"\") {\n var data_att_tmp1 = lines[i].split(data_distinquisher);\n var data_att_tmp2 = data_att_tmp1[1].split(',');\n data_name_sub = data_att_tmp2[0].replace('=\"', '');\n data_name_sub = data_name_sub.replace('\"', '');\n // json_object[data_name].push(data_name_sub);\n json_object[data_name][data_name_sub] = data_value;\n }\n if (data_distinquisher == \"\") {\n data_name_sub = \"value\";\n // json_object[data_name].push(data_name_sub);\n json_object[data_name][data_name_sub] = data_value;\n }\n\n json += '\"' + data_name + '\": {';\n json += '\"' + data_meta;\n json += 'value\": \"' + data_value + '\"},';\n }\n }\n }\n}\njson += '\"timestamp\": 123}';\n\n/*\nmsg.payload = data_name; // executor_queue_remaining_tasks\nnode.send(msg);\nmsg.payload = data_value; // 2.147483647E9\nnode.send(msg);\nmsg.payload = data_meta; // metric=\"openhab.core.metric.threadpools\",name=\"lsp\",openhab_core_metric=\"true\",pool=\"lsp\",\nnode.send(msg);\n*/\n\nmsg.payload = JSON.stringify(json_object);\nreturn msg;\n\n\n// executor_queue_remaining_tasks{metric=\"openhab.core.metric.threadpools\",name=\"lsp\",openhab_core_metric=\"true\",pool=\"lsp\",} 2.147483647E9\n",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "x": 400,
> "y": 740,
> "wires": [
> [
> "543607f4.df7328"
> ]
> ]
> },
> {
> "id": "543607f4.df7328",
> "type": "json",
> "z": "84ed84b2.83431",
> "name": "JSON2JSObject",
> "property": "payload",
> "action": "obj",
> "pretty": true,
> "x": 600,
> "y": 740,
> "wires": [
> [
> "a65939ae.ad9d88"
> ]
> ]
> },
> {
> "id": "9aa67c3f.8ef998",
> "type": "mqtt out",
> "z": "84ed84b2.83431",
> "name": "",
> "topic": "",
> "qos": "1",
> "retain": "true",
> "broker": "4672ca10.309984",
> "x": 1130,
> "y": 740,
> "wires": []
> },
> {
> "id": "a65939ae.ad9d88",
> "type": "function",
> "z": "84ed84b2.83431",
> "name": "Object2MQTT",
> "func": "for (let key in msg.payload){\n let msg1 = {payload:{}};\n // msg1.payload[key] = Object.assign(msg.payload[key],{\"key\":key});\n msg1.payload = Object.assign(msg.payload[key]);\n msg1.topic = \"openHAB/master/snmp/\" + msg.hostname + \"/\" + key;\n node.send(msg1)\n}\nreturn;",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "x": 800,
> "y": 740,
> "wires": [
> [
> "462efda4.e53c84"
> ]
> ]
> },
> {
> "id": "462efda4.e53c84",
> "type": "rbe",
> "z": "84ed84b2.83431",
> "name": "only changes",
> "func": "rbe",
> "gap": "",
> "start": "",
> "inout": "out",
> "property": "payload",
> "x": 990,
> "y": 740,
> "wires": [
> [
> "9aa67c3f.8ef998"
> ]
> ]
> },
> {
> "id": "de4a1af6.4ae9b",
> "type": "function",
> "z": "84ed84b2.83431",
> "name": "openHAB-Metrics",
> "func": "var msg1 = {payload:{\n \"hostname\": \"openhabmain\",\n \"hostip\": \"192.168.xx.xx\",\n \"metricsurl\": \"http://192.168.xx.xx:8080/rest/metrics/prometheus\"\n }};\n\nvar msg2 = {payload:{\n \"hostname\": \"openhabutilities\",\n \"hostip\": \"192.168.yy.yy\",\n \"metricsurl\": \"http://192.168.yy.yy:8080/rest/metrics/prometheus\"\n }};\n\nreturn [msg1, msg2];\n",
> "outputs": 2,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "x": 210,
> "y": 640,
> "wires": [
> [
> "c19dafd9.60b7c8"
> ],
> [
> "c19dafd9.60b7c8"
> ]
> ]
> },
> {
> "id": "c19dafd9.60b7c8",
> "type": "function",
> "z": "84ed84b2.83431",
> "name": "",
> "func": "// JSON parsen\n// parsed = JSON.parse(msg.payload);\n\nmsg.host = msg.payload.hostip;\nmsg.url = msg.payload.metricsurl;\nmsg.hostname = msg.payload.hostname;\n\nmsg.payload = \"los1\";\nreturn msg;\n",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "x": 480,
> "y": 640,
> "wires": [
> [
> "71173d2a.39309c"
> ]
> ]
> },
> {
> "id": "4672ca10.309984",
> "type": "mqtt-broker",
> "name": "Synology",
> "broker": "192.168.xx.xx",
> "port": "1883",
> "clientid": "nodered",
> "usetls": false,
> "compatmode": false,
> "keepalive": "60",
> "cleansession": true,
> "birthTopic": "openHAB/master/nodered",
> "birthQos": "2",
> "birthRetain": "true",
> "birthPayload": "ON",
> "closeTopic": "openHAB/master/nodered",
> "closeQos": "2",
> "closeRetain": "true",
> "closePayload": "OFF",
> "willTopic": "openHAB/master/nodered",
> "willQos": "2",
> "willRetain": "true",
> "willPayload": "OFF"
> }
> ]
> 
> ```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 November 2021 14:00 UTC](https://discourse.nodered.org/t/how-to-collect-information-from-multiple-sources-and-have-them-seperately-analyzed/52938/5 "2021-11-12T14:00:26Z")

</div>

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