Code Monkey home page Code Monkey logo

Comments (9)

kpetremann avatar kpetremann commented on June 12, 2024

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?

from mqtt-exporter.

xaxeu avatar xaxeu commented on June 12, 2024

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

@xaxeu, could you please:

  • share the configuration you used for the exporter (unless you kept the default values)
  • give the version of mqtt-exporter you are using

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

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

The full stacktrace would also be useful please

from mqtt-exporter.

marcio-m-sousa-alb avatar marcio-m-sousa-alb commented on June 12, 2024

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: - 9644:9000 environment: - MQTT_ADDRESS=xxxxxxxx - MQTT_PORT=xxxx - MQTT_TOPIC=PowerPUMP/measures/data restart: unless-stopped

I'm using latest tag version and I still dont' see the mqtt_relay_0 populated on Prometheus.

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

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 = (

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

Note: / in the key is supported since this PR: #41.

from mqtt-exporter.

xaxeu avatar xaxeu commented on June 12, 2024

Not sure why docker-compose up -d <container> didn't update to the latest tag, but used the pull command and now I have the metric relay/0 being transformed to mqtt_relay_0 on Prometheus.

Thanks.

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

👍

docker-compose up -d never pulls the image. You have to do docker-compose pull before.

You are welcome.

from mqtt-exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.