Node-red-contrib-prometheus-exporter

Hi there,
I am using Nodered to collect metrics from various sensors and store the output in influxDB.
I am now facing the need to expose my metrics to Prometheus. I have installed prometheus on a Raspberry Pi4 and looks like its working.
I have installed the node "node-red-contrib-prometheus-exporter" but as expected I am not really sure about how to use this node.
Is there anyone that has any experience with this node to guide me in getting it working?

Thank you

The readme seems to have a decent amount of info. Have you tried the example it has written up?

I am not a coder. Just hobby.
I am using this flow to store the metrics in InfluxDB. It is working fine.

[{"id":"f20693fd.b834c","type":"inject","z":"4e4990f3.d4ada","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":110,"y":80,"wires":[["755a63bbae97be1c","a7cb2c37.61171"]]},{"id":"a7cb2c37.61171","type":"exec","z":"4e4990f3.d4ada","command":"python -u /home/pi/Develop/ADS/adsTestAh4.py","addpay":false,"append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"Comm Analog","x":380,"y":80,"wires":[["e113dd69.db7cf"],[],[]]},{"id":"e113dd69.db7cf","type":"function","z":"4e4990f3.d4ada","name":"","func":"var t=msg.payload;\nif(t!==\"\")\n{\nk=t.split(':');\nfor (i = 0; i < k.length; i++)\n{\n    k[i]=parseFloat(k[i]);\n}\nmsg.topic=\"Analogues\";\n\tif(k[0]&&k[1]&&k[2]&&k[3]&&k[4]&&k[5])\n\t\t{\n\t\tmsg.payload={\"AP0\":k[0],\"AP1\":k[1],\"AP2\":k[2],\"AP3\":k[3],\"Ah\":k[4],\"InstP\":k[5]};\n\t\treturn msg;\n\n    }\n}\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":60,"wires":[["afcb27fb.7d26e8","e88b07f59c08c5e6"]]},{"id":"afcb27fb.7d26e8","type":"influxdb out","z":"4e4990f3.d4ada","influxdb":"b87cafc6.11924","name":"Analog-Influx","measurement":"check2","precision":"","retentionPolicy":"","database":"sensors","precisionV18FluxV20":"s","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":770,"y":100,"wires":[]},{"id":"e88b07f59c08c5e6","type":"debug","z":"4e4990f3.d4ada","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":40,"wires":[]},{"id":"b87cafc6.11924","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"datastorage","name":"","usetls":false,"tls":"","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true}]

I would love to see an example of how to expose the output of my function to Prometheus. Not having experience, I am not coming right with the info given on the node wiki.

I think I have fixed the issue. The Prometheus node is expecting an object, I was passing a number.
Passing an object resolved the issue.

1 Like

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