Closed xaxeu closed 1 year ago
hello @xaxeu,
Thanks for opening this issue.
This is because /
is not authorized in Prometheus metrics as explained in their documentation.
I can add a replace of /
to _
.
Would it be ok for you?
That would be perfect.
Thank you
A domingo, 2/04/2023, 16:48, Kevin Petremann @.***> escreveu:
hello @xaxeu https://github.com/xaxeu,
This is because / is not authorized in Prometheus metrics as explained in their documentation https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels.
I can add a replace of / to _.
Would it be ok for you?
— Reply to this email directly, view it on GitHub https://github.com/kpetremann/mqtt-exporter/issues/51#issuecomment-1493376607, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJCHCLSMH33HAVXPYBC6P3W7GNTLANCNFSM6AAAAAAWQF3FGU . You are receiving this because you were mentioned.Message ID: @.***>
@xaxeu, could you please:
This should already work as the replacement of \ to _ is already implemented.
I have added your case in unit tests, and I do see the relay/0
becoming relay_0
The full stacktrace would also be useful please
Hi,
Stacktrace:
Traceback (most recent call last): File "/opt/mqtt-exporter/exporter.py", line 5, in <module> main() File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 305, in main client.loop_forever() File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1756, in loop_forever rc = self._loop(timeout) File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1164, in _loop rc = self.loop_read() File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1556, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 2439, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle return self._handle_publish() File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3327, in _handle_publish self._handle_on_message(message) File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message on_message(self, self._userdata, message) File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 260, in expose_metrics _parse_metrics(payload, topic, userdata["client_id"]) File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 138, in _parse_metrics _create_prometheus_metric(prom_metric_name) File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 71, in _create_prometheus_metric prom_metrics[prom_metric_name] = Gauge( File "/usr/local/lib/python3.10/site-packages/prometheus_client/metrics.py", line 365, in __init__ super().__init__( File "/usr/local/lib/python3.10/site-packages/prometheus_client/metrics.py", line 130, in __init__ raise ValueError('Invalid metric name: ' + self._name) ValueError: Invalid metric name: mqtt_relay/0
Configuration on docker-compose: ` power_pump: image: kpetrem/mqtt-exporter:latest container_name: power_pump ports:
I'm using latest tag version and I still dont' see the mqtt_relay_0 populated on Prometheus.
can you provide me the output of docker compose images
command please? (or docker-compose images
if you still have the old version of compose)
I think you are still using an old version of the image. Maybe could you try to docker compose pull
?
Because, your stacktrace does not match the current code base:
File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 260, in expose_metrics _parse_metrics(payload, topic, userdata["client_id"])`
Actual code at line 260: # move availability suffix added by Zigbee2MQTT from topic to payload
File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 138, in _parse_metrics _create_prometheus_metric(prom_metric_name)`
Actual code at line 138: prom_metric_name = (
Note: /
in the key is supported since this PR: #41.
Not sure why docker-compose up -d \
Thanks.
:+1:
docker-compose up -d
never pulls the image. You have to do docker-compose pull
before.
You are welcome.
Describe the bug The following message:
PowerPUMP/measures/data {"app":"ESPURNA","version":"1.14.1","board":"ITEAD_SONOFF_POW_R2","host":"PowerPUMP","desc":"Powerpump","ssid":"iot","ip":"192.168.6.3","mac":"CC:50:E3:15:B7:38","rssi":-76,"uptime":4568436,"datetime":"2023-04-02 09:11:44","freeheap":18288,"relay/0":1,"vcc":3196,"loadavg":4,"time":"2023-04-02 09:11:44","id":91204}
provides following exception:
ValueError: Invalid metric name: mqtt_relay/0
Expected behavior It should allow '/' on the attribute key