# Node-red-contrib-prometheus-exporter

**URL:** <https://discourse.nodered.org/t/node-red-contrib-prometheus-exporter/49977>\
**Category:** General\
**Created:** [21 August 2021 05:11 UTC](https://discourse.nodered.org/t/node-red-contrib-prometheus-exporter/49977 "2021-08-21T05:11:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [21 August 2021 05:11 UTC](https://discourse.nodered.org/t/node-red-contrib-prometheus-exporter/49977/1 "2021-08-21T05:11:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 August 2021 06:30 UTC](https://discourse.nodered.org/t/node-red-contrib-prometheus-exporter/49977/2 "2021-08-21T06:30:54Z")

</div>

The [readme](https://flows.nodered.org/node/node-red-contrib-prometheus-exporter) seems to have a decent amount of info. Have you tried the example it has written up?

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [21 August 2021 06:43 UTC](https://discourse.nodered.org/t/node-red-contrib-prometheus-exporter/49977/3 "2021-08-21T06:43:00Z")

</div>

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

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [30 August 2021 08:53 UTC](https://discourse.nodered.org/t/node-red-contrib-prometheus-exporter/49977/4 "2021-08-30T08:53:03Z")

</div>

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.

---

<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:** [13 September 2021 08:53 UTC](https://discourse.nodered.org/t/node-red-contrib-prometheus-exporter/49977/5 "2021-09-13T08:53:44Z")

</div>

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