docoyo / node-red-contrib-prometheus-exporter Goto Github PK
View Code? Open in Web Editor NEWA NodeRED node which allows exporting Prometheus metrics from within flows.
License: Apache License 2.0
A NodeRED node which allows exporting Prometheus metrics from within flows.
License: Apache License 2.0
Example flows should be added to the examples section of the node.
The prometheus out node works fine after I click deploy the first time with a new metric name, and the metric shows up on the /metrics page.
But if I click on deploy a second time it will give me two errors in the debug panel:
And the nodered /metrics page becomes blank.
I'm looking for a feature where if the label changes, that the previous metric is deleted. And a new one with the new label value is created. I understand that the current behavior is also favorable for some scenarios. For counters this would make sense not for gauges.
Current behavior:
Let's say you set a metric with label A to 100. If you now change the label to B you get two lines.
metric{label="A"} 100
metric{label="B"} 100
Wanted behavior:
Let's say you set a metric with label A to 100. If you now change the label to B you get one line.
metric{label="B"} 100
This way if you do sum(metric)
you always get 100, instead of 200 with the previous method.
However this should not always be the case. You can have some labels that do this, some that don't
Let's say you have two power meters that have a tarrif. If the tarrif changes, you don't want extra lines, however you do want two lines, one for each meter.
power{meter="1", tariff="B"} 100
power{meter="2", tariff="A"} 50
Now if you do sum by (tariff) (power)
you get A=50, B=100
If there was some way to delete a metric, or do a label update without creating a new line, this would be possible.
Or perhaps you could configure which labels are changeable and which labels branch out the metric.
Hi,
I've installed the exporter on my Node-red instance living inside an Home Assistant OS.
I can setup the prometheus out
node and I can access the Node-red instance directly (not wrapped inside the Home Assistant gui) by accessing it via the port 1880.
When I try to access the metrics by going to http://my_server_ip:1880/metrics, I get a 404.
All I did is setup the prometheus out
node with data coming from an inject
node, am I missing anything?
Thank you very much in advance!
The following error is logged in the NodeRED debug console on complete deployment:
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Registry'
| property '_metrics' -> object with constructor 'Object'
| property 'MY_METRIC' -> object with constructor 'Gauge'
| property 'registers' -> object with constructor 'Array'
--- index 0 closes the circle
The node should also have support for the summary metric type.
At the moment, the Metric Name (and description) are statically settable only.
It would be great to have the possibility to use ENV variable, eg. similar to what is done with MQTT IN and OUT nodes.
I understand it can't be totally dynamic (through msg.payload.something). However, as ENV variables are initialized at runtime it would be a good solution. IMHO.
Thanks for the node anyway :)
Hi,
leaving the labels empty in the configuration lead to this error:
27 Mar 18:40:18 - [error] [prometheus-metric-config:c33c5a05.e101f8] TypeError: Cannot read property 'length' of undefined
Having at least 1 label fix this issue, while labels should be optional.
A PR will follow.
Kind regards,
Would be handy to have a set value option in the counter like guage. The source I'm using (Total kWh in a energy meter) so I just need to set the value not increase it by a certain amount.
Hi,
for certain reasons we need to "delete" specific exposed metrics.
So it would be nice if you can add a "del" operation.
This operation should remove the currently exposed metric (minding the given labels) from the /metrics endpoint.
So that Prometheus doesn't retrieve a value.
example:
{ "op": "del", "labels": { "tag_1": "computer_123" } }
The node should also have support for the histogram metric type.
The style rules applied to the config dialog are applied not just to the Prometheus configuration but to all nodes.
The fix is relatively easy and would prevent the Prometheus node from interfering with CSS rules applied to other nodes.
For example the ones we have been developing.
See my PR
I am having problems with this node:
[{"id":"cc08c4d980616d50","type":"rpi-gpio in","z":"4e4990f3.d4ada","name":"Digi1","pin":"33","intype":"tri","debounce":"250","read":true,"x":190,"y":560,"wires":[["eac0b39954ba4df6","4b48f8c4ecf91f7a","7642286748afd7c9"]]},{"id":"eac0b39954ba4df6","type":"debug","z":"4e4990f3.d4ada","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":350,"y":540,"wires":[]},{"id":"4b48f8c4ecf91f7a","type":"influxdb out","z":"4e4990f3.d4ada","influxdb":"b87cafc6.11924","name":"Digi1-Influx","measurement":"Digi1","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":350,"y":580,"wires":[]},{"id":"7642286748afd7c9","type":"change","z":"4e4990f3.d4ada","name":"prom-exporter-digi1","rules":[{"t":"set","p":"payload.val","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload.op","pt":"msg","to":"set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":560,"wires":[["d6a1c7879f44da0b"]]},{"id":"d6a1c7879f44da0b","type":"prometheus-exporter","z":"4e4990f3.d4ada","name":"","metric":"8ae66ae189b4f751","x":810,"y":560,"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},{"id":"8ae66ae189b4f751","type":"prometheus-metric-config","name":"raspberrypi_digi1","help":"Digi 1","labels":"","mtype":"counter"}]
The errors are generated on status change of the pin. I have a node detecting if the GPIO is high or low and posting a 0/1 output. However, every time the status change, errors are generated. I did try in both configurations gauge and counter but I always get the same type of error.
I have other 5 nodes working properly in the same flow but this one is giving me troubles and I do not understand why.
I can't seem to get any output to my Node-RED metrics page.
I've setup a single counter output setup, fed by a Inject node (firing every second) through a Template node:
[{"id":"271e5e391962b383","type":"inject","z":"cae39ee2.e2c898","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":340,"y":200,"wires":[["b74cf7ca73e55ee4"]]},{"id":"b74cf7ca73e55ee4","type":"template","z":"cae39ee2.e2c898","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"plain","template":"{\n \"op\": \"inc\"\n}","output":"str","x":560,"y":100,"wires":[["ea8507f4388b7b5f","106518794a79dd30"]]},{"id":"ea8507f4388b7b5f","type":"prometheus-exporter","z":"cae39ee2.e2c898","name":"metric_temp-BK","metric":"f7b80ed39105d802","x":740,"y":100,"wires":[]},{"id":"f7b80ed39105d802","type":"prometheus-metric-config","name":"temp-BK","help":"Boil kettle temperaure","labels":"","mtype":"counter"}]
Am I missing something?
The SERVERIP:1880/metrics page is simply blank.
Everything is running directly on metal - no docker, iptables or anything else set.
Program versions:
node-red-contrib-prometheus-exporter v1.0.5
Prometheus version:
prometheus, version 2.29.1 (branch: HEAD, revision: dcb07e8eac34b5ea37cd229545000b857f1c1637)
build user: root@9f54ccae6d42
build date: 20210811-14:38:07
go version: go1.16.7
platform: linux/arm
node_exporter, version 1.2.2 (branch: HEAD, revision: 26645363b486e12be40af7ce4fc91e731a33104e)
build user: root@1c3411405b8f
build date: 20210806-13:43:27
go version: go1.16.7
platform: linux/arm
Node-RED version: v2.0.5
Node.js version: v14.17.3
Linux 5.10.52+ arm LE
Running on RPi Zero W
Linux raspberrypi 5.10.52+ #1441 Tue Aug 3 18:08:18 BST 2021 armv6l GNU/Linux
Hi. I have an array of events. I used the split component to send each one individually to my prometheus exporter. But when I go to /metrics, I only see the last one. (flow attached)
Am I not using the exporter correctly?
It shall be possible to optionally set the timestamp of the metric value via msg.payload.timestamp.
When I try to build a metric with a decimal part, I get an error:
"Missing val for metric type gauge"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.