Code Monkey home page Code Monkey logo

Comments (11)

kpetremann avatar kpetremann commented on June 12, 2024 1

To use the filter you simply need to put the original topic in: MQTT_IGNORED_TOPICS.
I don't know what is the original topic in your case from the info you provided.

I have a docker compose mqtt-exporter setup, how could I implement that pull request?

The easiest way is to

  • git clone the repository
  • checkout the crash_bad_char_metric_name branch
  • run the docker compose with docker-compose.dev.yml file

As an example, I have myself a docker-compose with both stable mqtt-exporter + the dev version built from the disk:

version: "3"
  services:

    mqtt-exporter:
      image: kpetrem/mqtt-exporter
    environment:
      ...

    mqtt-exporter-dev:
      build: /home/kevin/dev/mqtt-exporter
      environment:
      ...

from mqtt-exporter.

amigthea avatar amigthea commented on June 12, 2024 1

perfect! it doesn't crash anymore, thank you for this amazing fix!

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024 1

you are welcome.
This has been included in the release 1.2.0

from mqtt-exporter.

amigthea avatar amigthea commented on June 12, 2024

I need at least a workaround to exclude certain metric to be picked up by mqtt-exporter, how can I achieve that?

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

hello @amigthea,

Thanks for raising the issue.

mqtt_cpu_usages_%Cpu:_mem means that your original topic was cpu_usages_%Cpu:_mem.
% is not a valid character for Prometheus. See details here.

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

#56 should fix your issue. Could you please try?

from mqtt-exporter.

amigthea avatar amigthea commented on June 12, 2024

hello @amigthea,

Thanks for raising the issue.

mqtt_cpu_usages_%Cpu:_mem means that your original topic was cpu_usages_%Cpu:_mem. % is not a valid character for Prometheus. See details here.

#56 should fix your issue. Could you please try?

hi @kpetremann and thank you for joining the discussion
It's indeed a kind of metric not parsed for prometheus, I was trying to figure out a workaround on how to esclude that topic with the MQTT_IGNORED_TOPICS enviroment variable, but I'll gladly try out that fix instead!
I have a docker compose mqtt-exporter setup, how could I implement that pull request?

from mqtt-exporter.

amigthea avatar amigthea commented on June 12, 2024

That's awesome, thank you for that workflow! However now I get a KeyError instead of a ValueError

INFO:mqtt-exporter:creating prometheus metric: mqtt_detectors_coral_inference_speed
INFO:mqtt-exporter:creating prometheus metric: mqtt_detectors_coral_detection_start
INFO:mqtt-exporter:creating prometheus metric: mqtt_detectors_coral_pid
INFO:mqtt-exporter:creating prometheus metric: mqtt_detection_fps
INFO:mqtt-exporter:creating prometheus metric: mqtt_cpu_usages_Tasks:_mem
INFO:mqtt-exporter:creating prometheus metric: mqtt_cpu_usages_Cpu:_mem
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 365, 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 320, in expose_metrics
    _parse_metrics(payload, topic, userdata["client_id"])
  File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 151, in _parse_metrics
    _parse_metrics(value, topic, client_id, f"{prefix}{metric}_")
  File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 151, in _parse_metrics
    _parse_metrics(value, topic, client_id, f"{prefix}{metric}_")
  File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 171, in _parse_metrics
    _add_prometheus_sample(topic, prom_metric_name, metric_value, client_id)
  File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 105, in _add_prometheus_sample
    prom_metrics[prom_metric_name].labels(**labels).set(metric_value)
KeyError: 'mqtt_cpu_usages_%Cpu:_mem'
mqtt-exporter-dev exited with code 0

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

ok I see. I'll fix that.
@amigthea could you provide the original MQTT message please? It could help to add a functional test.

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

actually it is not needed. I have an easy way to test that.

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

should be better now. Could you git pull and try again?

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.