Code Monkey home page Code Monkey logo

mqtt-exporter's Introduction

Automation enthusiast

A little about me

Currently a proud SRE@Criteo in the Network Datacenter team.

  • πŸ”­ I’m currently working on AFK, the new Criteo's network automation framework.
  • πŸ”§ Actively maintaining Salt Exporter and MQTT Exporter
  • πŸ’¬ Ask me about Python, Golang, Network, Salt, OpenConfig, SONiC

Articles

For Criteo:

Personal:

My personal projects

Project Category Opensource Status Tech
Salt Exporter Infrastructure, observability true stable Go
MQTT Exporter IoT, observability true stable Python
DHT2MQTT IoT true alpha Go
ClawNetwork Infrastructure true alpha Go
2D game Game development false prototype Go, Ebitengine, LDTK

My professional projects

Project Category Opensource Status Tech
netprobify Probing true stable Python
AFK Infrastructure, network, automation true alpha Go, Python, Salt, NetBox

Languages and Tools

Support

If you like my personal projects, don't hesitate to buy me a coffee :)

Buy Me A Coffee

mqtt-exporter's People

Contributors

adamcstephens avatar baurmatt avatar christoph-heiss avatar jengo avatar kpetremann avatar matthew-beckett avatar mortenlj avatar nanassito avatar onedr0p avatar r0ckarong avatar rin avatar rixxxx avatar roobre avatar the-jc avatar thspinto avatar zubairov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mqtt-exporter's Issues

Support esphome format

Hello,

I have lot of esphome device and I want to transfert data from esphome to prometheus, I try mqtt-exporter but format of mqtt message of esphome is not supported, example of topic :
esp-weather-outdoor/sensor/temperature/state => 8.1

It's like <prefix>/<name>/sensor/temperature (shelly) but with state at the end.

Is it possible to handle that ?

Thank in advance.

Failed to export anything except permit_join

Great tool BTW, exactly what I was looking for, however....

I'm running the latest version of the exporter like this:

docker run -it --rm -p 9110:9000 -e "MQTT_ADDRESS=192.168.178.56" -e "LOG_LEVEL=DEBUG" kpetrem/mqtt-exporter

Getting this output:

DEBUG:mqtt-exporter:failed to parse as JSON: "b'online'"
DEBUG:mqtt-exporter:Failed to convert commit: cb9699e
DEBUG:mqtt-exporter:Failed to convert coordinator: {'meta': {'maintrel': 3, 'majorrel': 2, 'minorrel': 6, 'product': 0, 'revision': 20190608, 'transportrev': 2}, 'type': 'zStack12'}
DEBUG:mqtt-exporter:Failed to convert log_level: info
DEBUG:mqtt-exporter:Failed to convert network: {'channel': 11, 'extendedPanID': '0xdddddddddddddddd', 'panID': 6754}
INFO:mqtt-exporter:creating prometheus metric: mqtt_permit_join
DEBUG:mqtt-exporter:new value for mqtt_permit_join: 1.0
DEBUG:mqtt-exporter:Failed to convert version: 1.16.1

and can only see these measurements:

# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 119.0
python_gc_objects_collected_total{generation="1"} 257.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 38.0
python_gc_collections_total{generation="1"} 3.0
python_gc_collections_total{generation="2"} 0.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="8",patchlevel="6",version="3.8.6"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 2.369536e+07
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.7379328e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.60624716527e+09
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.22
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 10.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP mqtt_permit_join metric generated from MQTT message.
# TYPE mqtt_permit_join gauge
mqtt_permit_join{topic="zigbee2mqtt_bridge_config"} 1.0

The zigbee2mqtt log looks like this:

Zigbee2MQTT:info  2020-11-24 20:26:36: Logging to console and directory: '/opt/zigbee2mqtt/data/log/2020-11-24.20-26-35' filename: log.txt
Zigbee2MQTT:info  2020-11-24 20:26:37: Starting Zigbee2MQTT version 1.16.1 (commit #cb9699e)
Zigbee2MQTT:info  2020-11-24 20:26:37: Starting zigbee-herdsman...
Zigbee2MQTT:info  2020-11-24 20:26:39: zigbee-herdsman started
Zigbee2MQTT:info  2020-11-24 20:26:39: Coordinator firmware version: '{"meta":{"maintrel":3,"majorrel":2,"minorrel":6,"product":0,"revision":20190608,"transportrev":2},"type":"zStack12"}'
Zigbee2MQTT:info  2020-11-24 20:26:40: Currently 0 devices are joined:
Zigbee2MQTT:warn  2020-11-24 20:26:40: `permit_join` set to  `true` in configuration.yaml.
Zigbee2MQTT:warn  2020-11-24 20:26:40: Allowing new devices to join.
Zigbee2MQTT:warn  2020-11-24 20:26:40: Set `permit_join` to `false` once you joined all devices.
Zigbee2MQTT:info  2020-11-24 20:26:40: Zigbee: allowing new devices to join.
Zigbee2MQTT:info  2020-11-24 20:26:40: Connecting to MQTT server at mqtt://localhost
Zigbee2MQTT:info  2020-11-24 20:26:40: Connected to MQTT server
Zigbee2MQTT:info  2020-11-24 20:26:40: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload 'online'
Zigbee2MQTT:info  2020-11-24 20:26:40: MQTT publish: topic 'zigbee2mqtt/bridge/config', payload '{"commit":"cb9699e","coordinator":{"meta":{"maintrel":3,"majorrel":2,"minorrel":6,"product":0,"revision":20190608,"transportrev":2},"type":"zStack12"},"log_level":"info","network":{"channel":11,"extendedPanID":"0xdddddddddddddddd","panID":6754},"permit_join":true,"version":"1.16.1"}'
Zigbee2MQTT:info  2020-11-24 20:32:27: Device '0x00158d00024a13d1' joined
Zigbee2MQTT:info  2020-11-24 20:32:27: Starting interview of '0x00158d00024a13d1'

I can not connect

Hello, it is not an error that I am reporting but, I cannot get mqtt-exporter to extract the metrics from my mqtt server hosted on a raspberry that is reachable locally, I do not see errors in the log, I execute through the console

mosquitto_sub -h 192.168.105.112 -p 1883 -v -t '#'

Ouput

solar_assistant/inverter_1/charger_source_priority/state Solar and utility simultaneously
solar_assistant/inverter_1/max_charge_current/state 60
solar_assistant/inverter_1/battery_absorption_charge_voltage/state 28.2
solar_assistant/inverter_1/to_grid_battery_voltage/state 23.0
solar_assistant/inverter_1/serial_number/state 96112307100039
solar_assistant/inverter_1/solar_power_priority/state Battery/Load/Utility
solar_assistant/inverter_1/battery_float_charge_voltage/state 27.0
solar_assistant/inverter_1/max_grid_charge_current/state 30
solar_assistant/inverter_1/output_source_priority/state Solar/Utility/Battery
solar_assistant/inverter_1/shutdown_battery_voltage/state 21.0
solar_assistant/inverter_1/back_to_battery_voltage/state 27.0

But when I try to do it through mqtt-exporter I can't get anything. I hope you can help me.

I will attach the configuration of how it is being done.

# Docker compose

mqtt-exporter:
    container_name: mqtt-exporter
    image: kpetrem/mqtt-exporter
    environment:
      - MQTT_ADDRESS=192.168.105.112
    ports:
      - 9001:9000
    restart: unless-stopped

# Prometheus config

- job_name: mqtt-exporter
    static_configs:
      - targets: ["mqtt-exporter:9001"]

# Log container 

mqtt-exporter-1             | INFO:mqtt-exporter:subscribing to "#"
mqtt-exporter-1             | INFO:mqtt-exporter:creating prometheus metric: PromMetricId(name='sensor_state', labels=())

image

Change the default port since I use portainer and it publishes on port 9000, now I get this:

# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 187.0
python_gc_objects_collected_total{generation="1"} 42.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 44.0
python_gc_collections_total{generation="1"} 4.0
python_gc_collections_total{generation="2"} 0.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="10",patchlevel="13",version="3.10.13"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 2.748416e+07
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.9951616e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.70810707506e+09
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.54
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 8.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP mqtt_message_total Counter of received messages
# TYPE mqtt_message_total counter
mqtt_message_total{topic="solar_assistant_inverter_1"} 62.0
mqtt_message_total{topic="homeassistant_sensor_solar_assistant_set_response_message_config"} 1.0
mqtt_message_total{topic="solar_assistant_total"} 6.0
# HELP mqtt_message_created Counter of received messages
# TYPE mqtt_message_created gauge
mqtt_message_created{topic="solar_assistant_inverter_1"} 1.7081070759833767e+09
mqtt_message_created{topic="homeassistant_sensor_solar_assistant_set_response_message_config"} 1.7081070759885392e+09
mqtt_message_created{topic="solar_assistant_total"} 1.7081070766748183e+09
# HELP mqtt_state metric generated from MQTT message.
# TYPE mqtt_state gauge
mqtt_state{topic="solar_assistant_inverter_1"} 0.0
mqtt_state{topic="solar_assistant_total"} 100.0

Shelly metrics reporting as zero

I'm trying to use mqtt-exporter to expose some values from a Shelly EM. Running with LOG_LEVEL=DEBUG, I see the following output with each MQTT message published:

DEBUG:mqtt-exporter:failed to parse payload as JSON: "b'off'"
DEBUG:mqtt-exporter:new value for mqtt_power: 1647.29
DEBUG:mqtt-exporter:new value for mqtt_reactive_power: -458.5
DEBUG:mqtt-exporter:new value for mqtt_voltage: 241.64
DEBUG:mqtt-exporter:new value for mqtt_total: 30483.3
DEBUG:mqtt-exporter:new value for mqtt_total_returned: 0.0
DEBUG:mqtt-exporter:new value for mqtt_power: 0.0
DEBUG:mqtt-exporter:new value for mqtt_reactive_power: 0.0
DEBUG:mqtt-exporter:new value for mqtt_voltage: 241.64
DEBUG:mqtt-exporter:new value for mqtt_total: 0.0
DEBUG:mqtt-exporter:new value for mqtt_total_returned: 0.0
DEBUG:mqtt-exporter:new value for mqtt_energy: 1677
DEBUG:mqtt-exporter:new value for mqtt_returned_energy: 0
DEBUG:mqtt-exporter:new value for mqtt_energy: 0
DEBUG:mqtt-exporter:new value for mqtt_returned_energy: 0

All good so far. Then, on the /metrics output, the following:

# HELP mqtt_message_total Counter of received messages
# TYPE mqtt_message_total counter
mqtt_message_total{topic="shellies_shellyem"} 68.0
# HELP mqtt_message_created Counter of received messages
# TYPE mqtt_message_created gauge
mqtt_message_created{topic="shellies_shellyem"} 1.6490785172786949e+09
# HELP mqtt_power metric generated from MQTT message.
# TYPE mqtt_power gauge
mqtt_power{topic="shellies_shellyem"} 0.0
# HELP mqtt_reactive_power metric generated from MQTT message.
# TYPE mqtt_reactive_power gauge
mqtt_reactive_power{topic="shellies_shellyem"} 0.0
# HELP mqtt_voltage metric generated from MQTT message.
# TYPE mqtt_voltage gauge
mqtt_voltage{topic="shellies_shellyem"} 240.1
# HELP mqtt_total metric generated from MQTT message.
# TYPE mqtt_total gauge
mqtt_total{topic="shellies_shellyem"} 0.0
# HELP mqtt_total_returned metric generated from MQTT message.
# TYPE mqtt_total_returned gauge
mqtt_total_returned{topic="shellies_shellyem"} 0.0
# HELP mqtt_energy metric generated from MQTT message.
# TYPE mqtt_energy gauge
mqtt_energy{topic="shellies_shellyem-"} 0.0
# HELP mqtt_returned_energy metric generated from MQTT message.
# TYPE mqtt_returned_energy gauge
mqtt_returned_energy{topic="shellies_shellyem"} 0.0

So it seems that most of the values are being lost at output time. Are you able to see why this is happening?

# in MQTT_TOPIC not working.

Describe the bug
A clear and concise description of what the bug is

the client is subscribing to # but the exporter doesn't have any metrics

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
mqtt-exporter:
image: kpetrem/mqtt-exporter
ports:
- 9000:9000
environment:
- MQTT_ADDRESS=url.info.com
- MQTT_PORT=1883
- MQTT_USERNAME=user
- MQTT_PASSWORD=pass
- LOG_LEVEL=DEBUG
- KEEP_FULL_TOPIC=True

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
When i then query my /metrics at my address there is no metrics shown whatsoever.

DEBUG:mqtt-exporter:Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b''
DEBUG:mqtt-exporter:Received CONNACK (0, 0)
INFO:mqtt-exporter:subscribing to "#"
DEBUG:mqtt-exporter:Sending SUBSCRIBE (d0, m1) [(b'#', 0)]
DEBUG:mqtt-exporter:Received SUBACK

AttributeError: 'Properties' object has no attribute 'AssignedClientIdentifier'

Hi Thanks for you package!

Testing a vanilla pip install in /tmp I get:

ERROR:mqtt-exporter:Caught exception in on_connect: 'Properties' object has no attribute 'AssignedClientIdentifier'
Traceback (most recent call last):
  File "/tmp/mqtt-exporter/exporter.py", line 6, in <module>
    main()
  File "/tmp/mqtt-exporter/mqtt_exporter/main.py", line 460, in main
    client.loop_forever()
  File "/tmp/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 2291, in loop_forever
    rc = self._loop(timeout)
         ^^^^^^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1680, in _loop
    rc = self.loop_read()
         ^^^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 2094, in loop_read
    rc = self._packet_read()
         ^^^^^^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3137, in _packet_read
    rc = self._packet_handle()
         ^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3809, in _packet_handle
    return self._handle_connack()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3929, in _handle_connack
    on_connect(
  File "/tmp/mqtt-exporter/mqtt_exporter/main.py", line 62, in subscribe
    user_data["client_id"] = properties.AssignedClientIdentifier
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Properties' object has no attribute 'AssignedClientIdentifier'

Environment:

$ pip freeze
paho-mqtt==2.0.0
prometheus_client==0.20.0

$ uname -a
Linux 6.6.15-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.6.15-2 (2024-02-04) x86_64 GNU/Linux

python --version
Python 3.11.8

Ah, digging into it a little, it appears that we really need a client-id nowadays.
So either set a default client id in settings.py (e.g. mqtt-exporter), or change the start instruction to:

MQTT_CLIENT_ID=mqtt-exporter MQTT_ADDRESS=192.168.0.1 python exporter.py

emporiavue2/esphome support

Hey, it is me again πŸ˜‚ πŸ˜„

Today I flashed Emporia Vue with esphome - https://github.com/emporia-vue-local/esphome

And I managed to get it in mqtt:
image

Topic:

emporiavue2/sensor/circuit_3_power/state

Value is a raw number with energy usage

In the form you are using:

topic '<prefix>/sensor/<name>/state' '20.00'

I don't see it on output, but I see the topics are being counted:

# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 1.39416e+06
python_gc_objects_collected_total{generation="1"} 125827.0
python_gc_objects_collected_total{generation="2"} 1656.0
# HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 1660.0
python_gc_collections_total{generation="1"} 150.0
python_gc_collections_total{generation="2"} 2.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="10",patchlevel="12",version="3.10.12"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 2.7521024e+07
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.9939328e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.68814506766e+09
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 151.46
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 8.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP mqtt_message_total Counter of received messages
# TYPE mqtt_message_total counter
mqtt_message_total{topic="hubitat_home-hub_bedroom button aircon"} 54.0
mqtt_message_total{topic="hubitat_home-hub_bedroom light"} 39.0
mqtt_message_total{topic="hubitat_home-hub_big desk button monitors"} 54.0
mqtt_message_total{topic="hubitat_home-hub_pc power switch"} 5897.0
mqtt_message_total{topic="hubitat_home-hub_living room main light"} 43.0
mqtt_message_total{topic="glow_C4DD57D80A24_STATE"} 8693.0
mqtt_message_total{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 8688.0
mqtt_message_total{topic="hubitat_home-hub_bedroom light strip"} 2.0
mqtt_message_total{topic="homeassistant_button_emporiavue2_two_beeps_config"} 8.0
mqtt_message_total{topic="homeassistant_light_emporiavue2_d3_led_config"} 8.0
mqtt_message_total{topic="emporiavue2_light_d3_led_state"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_phase_a_voltage_config"} 8.0
mqtt_message_total{topic="esphome_discover_emporiavue2"} 8.0
mqtt_message_total{topic="emporiavue2_sensor"} 112473.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_phase_a_frequency_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_phase_a_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_phase_a_power_return_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_1_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_2_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_3_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_4_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_5_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_6_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_7_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_8_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_9_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_10_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_11_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_12_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_13_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_14_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_15_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_16_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_total_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_total_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_balance_power_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_balance_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_total_power_return_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_total_daily_energy_return_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_1_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_2_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_3_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_4_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_5_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_6_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_7_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_8_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_9_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_10_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_11_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_12_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_13_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_14_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_15_daily_energy_config"} 8.0
mqtt_message_total{topic="homeassistant_sensor_emporiavue2_circuit_16_daily_energy_config"} 8.0
mqtt_message_total{topic="hubitat_home-hub_heartbeat"} 612.0
# HELP mqtt_message_created Counter of received messages
# TYPE mqtt_message_created gauge
mqtt_message_created{topic="hubitat_home-hub_bedroom button aircon"} 1.6881450690604203e+09
mqtt_message_created{topic="hubitat_home-hub_bedroom light"} 1.6881450690609236e+09
mqtt_message_created{topic="hubitat_home-hub_big desk button monitors"} 1.688145069061259e+09
mqtt_message_created{topic="hubitat_home-hub_pc power switch"} 1.688145069062229e+09
mqtt_message_created{topic="hubitat_home-hub_living room main light"} 1.6881450691002738e+09
mqtt_message_created{topic="glow_C4DD57D80A24_STATE"} 1.6881450716572747e+09
mqtt_message_created{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 1.6881450716623971e+09
mqtt_message_created{topic="hubitat_home-hub_bedroom light strip"} 1.688208620907931e+09
mqtt_message_created{topic="homeassistant_button_emporiavue2_two_beeps_config"} 1.688221654495132e+09
mqtt_message_created{topic="homeassistant_light_emporiavue2_d3_led_config"} 1.688221654501135e+09
mqtt_message_created{topic="emporiavue2_light_d3_led_state"} 1.68822165450141e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_phase_a_voltage_config"} 1.6882216545107183e+09
mqtt_message_created{topic="esphome_discover_emporiavue2"} 1.6882216545444884e+09
mqtt_message_created{topic="emporiavue2_sensor"} 1.688221654544677e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_phase_a_frequency_config"} 1.688221654544888e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_phase_a_power_config"} 1.6882216545452168e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_phase_a_power_return_config"} 1.6882216545454895e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_1_power_config"} 1.6882216545507493e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_2_power_config"} 1.6882216545511165e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_3_power_config"} 1.6882216545766337e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_4_power_config"} 1.688221654576937e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_5_power_config"} 1.6882216545772138e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_6_power_config"} 1.688221654591104e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_7_power_config"} 1.688221654591468e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_8_power_config"} 1.6882216546098795e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_9_power_config"} 1.6882216546101801e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_10_power_config"} 1.6882216546105118e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_11_power_config"} 1.6882216546158414e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_12_power_config"} 1.6882216546337502e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_13_power_config"} 1.6882216546340964e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_14_power_config"} 1.6882216546343696e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_15_power_config"} 1.688221654640501e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_16_power_config"} 1.6882216546408718e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_total_power_config"} 1.688221654662191e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_total_daily_energy_config"} 1.6882216546624844e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_balance_power_config"} 1.6882216546627667e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_balance_daily_energy_config"} 1.6882216546718016e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_total_power_return_config"} 1.688221654692498e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_total_daily_energy_return_config"} 1.688221654692848e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_1_daily_energy_config"} 1.688221654693142e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_2_daily_energy_config"} 1.6882216546976118e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_3_daily_energy_config"} 1.6882216546979318e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_4_daily_energy_config"} 1.688221654718868e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_5_daily_energy_config"} 1.688221654719283e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_6_daily_energy_config"} 1.6882216547263021e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_7_daily_energy_config"} 1.6882216547268195e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_8_daily_energy_config"} 1.688221654749463e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_9_daily_energy_config"} 1.6882216547498114e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_10_daily_energy_config"} 1.6882216547566402e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_11_daily_energy_config"} 1.6882216547569463e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_12_daily_energy_config"} 1.6882216547736392e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_13_daily_energy_config"} 1.6882216547739484e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_14_daily_energy_config"} 1.6882216547742496e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_15_daily_energy_config"} 1.6882216547787926e+09
mqtt_message_created{topic="homeassistant_sensor_emporiavue2_circuit_16_daily_energy_config"} 1.6882216548268838e+09
mqtt_message_created{topic="hubitat_home-hub_heartbeat"} 1.6882341259519696e+09
# HELP mqtt_lastCheckinEpoch metric generated from MQTT message.
# TYPE mqtt_lastCheckinEpoch gauge
mqtt_lastCheckinEpoch{topic="hubitat_home-hub_bedroom button aircon"} 1.688218585746e+012
mqtt_lastCheckinEpoch{topic="hubitat_home-hub_bedroom light"} 1.688216204251e+012
mqtt_lastCheckinEpoch{topic="hubitat_home-hub_big desk button monitors"} 1.688219217504e+012
mqtt_lastCheckinEpoch{topic="hubitat_home-hub_living room main light"} 1.688219060401e+012
# HELP mqtt_battery metric generated from MQTT message.
# TYPE mqtt_battery gauge
mqtt_battery{topic="hubitat_home-hub_bedroom button aircon"} 100.0
mqtt_battery{topic="hubitat_home-hub_big desk button monitors"} 97.0
# HELP mqtt_power metric generated from MQTT message.
# TYPE mqtt_power gauge
mqtt_power{topic="hubitat_home-hub_pc power switch"} 243.0
# HELP mqtt_voltage metric generated from MQTT message.
# TYPE mqtt_voltage gauge
mqtt_voltage{topic="hubitat_home-hub_pc power switch"} 250.0
# HELP mqtt_energy metric generated from MQTT message.
# TYPE mqtt_energy gauge
mqtt_energy{topic="hubitat_home-hub_pc power switch"} 5.68
# HELP mqtt_amperage metric generated from MQTT message.
# TYPE mqtt_amperage gauge
mqtt_amperage{topic="hubitat_home-hub_pc power switch"} 0.995
# HELP mqtt_energyCost metric generated from MQTT message.
# TYPE mqtt_energyCost gauge
mqtt_energyCost{topic="hubitat_home-hub_pc power switch"} 1.21
# HELP mqtt_hourlyEnergy metric generated from MQTT message.
# TYPE mqtt_hourlyEnergy gauge
mqtt_hourlyEnergy{topic="hubitat_home-hub_pc power switch"} 0.03
# HELP mqtt_han_rssi metric generated from MQTT message.
# TYPE mqtt_han_rssi gauge
mqtt_han_rssi{topic="glow_C4DD57D80A24_STATE"} -73.0
# HELP mqtt_han_lqi metric generated from MQTT message.
# TYPE mqtt_han_lqi gauge
mqtt_han_lqi{topic="glow_C4DD57D80A24_STATE"} 108.0
# HELP mqtt_electricitymeter_energy_export_cumulative metric generated from MQTT message.
# TYPE mqtt_electricitymeter_energy_export_cumulative gauge
mqtt_electricitymeter_energy_export_cumulative{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 0.0
# HELP mqtt_electricitymeter_energy_import_cumulative metric generated from MQTT message.
# TYPE mqtt_electricitymeter_energy_import_cumulative gauge
mqtt_electricitymeter_energy_import_cumulative{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 24268.301
# HELP mqtt_electricitymeter_energy_import_day metric generated from MQTT message.
# TYPE mqtt_electricitymeter_energy_import_day gauge
mqtt_electricitymeter_energy_import_day{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 16.45
# HELP mqtt_electricitymeter_energy_import_mpan metric generated from MQTT message.
# TYPE mqtt_electricitymeter_energy_import_mpan gauge
mqtt_electricitymeter_energy_import_mpan{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 1.30000117248e+012
# HELP mqtt_electricitymeter_energy_import_price_unitrate metric generated from MQTT message.
# TYPE mqtt_electricitymeter_energy_import_price_unitrate gauge
mqtt_electricitymeter_energy_import_price_unitrate{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 0.3476
# HELP mqtt_electricitymeter_energy_import_price_standingcharge metric generated from MQTT message.
# TYPE mqtt_electricitymeter_energy_import_price_standingcharge gauge
mqtt_electricitymeter_energy_import_price_standingcharge{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 0.6018
# HELP mqtt_electricitymeter_power_value metric generated from MQTT message.
# TYPE mqtt_electricitymeter_power_value gauge
mqtt_electricitymeter_power_value{topic="glow_C4DD57D80A24_SENSOR_electricitymeter"} 0.555
# HELP mqtt_level metric generated from MQTT message.
# TYPE mqtt_level gauge
mqtt_level{topic="hubitat_home-hub_bedroom light strip"} 100.0
# HELP mqtt_clrm metric generated from MQTT message.
# TYPE mqtt_clrm gauge
mqtt_clrm{topic="homeassistant_light_emporiavue2_d3_led_config"} 1.0
# HELP mqtt_state metric generated from MQTT message.
# TYPE mqtt_state gauge
mqtt_state{topic="emporiavue2_light_d3_led_state"} 1.0
mqtt_state{topic="emporiavue2_sensor"} 63.9
# HELP mqtt_port metric generated from MQTT message.
# TYPE mqtt_port gauge
mqtt_port{topic="esphome_discover_emporiavue2"} 6053.0
# HELP mqtt_home_hub metric generated from MQTT message.
# TYPE mqtt_home_hub gauge
mqtt_home_hub{topic="hubitat_home-hub_heartbeat"} 1.688237830102e+012

Shelly Plus H&T topic format not working with exporter

I just bought two of these devices and updated them to Firmware 1.0.8 as suggested by the Web UI.
I configured MQTT fine and the messages are showing up in my mosquitto broker instance.

What I can't seem to make work is the other end to write this stuff to my prometheus instance.

For my devices, the shelly topic structure looks like this:

Screenshot from 2023-12-07 18-26-38

For me it is not <prefix>/<name>/sensor/temperature it's <prefix>/<name>/status/temperature:0.

I've got another mqtt exporter tool working for my tasmota device and it's working fine there. I just don't understand what I'm doing wrong with your tool that it just seems to do nothing.

Here are the relevant snippets of my configs:

docker-compose.yaml

[...]
  prometheus:
    container_name: prometheus
    image: prom/prometheus:v2.48.0
    restart: unless-stopped
    volumes:
      - ./prometheus/:/etc/prometheus/
      # Make sure the folder on the filesystem is owned by 65534:65534
      - ./prometheus/tsdb:/tsdb/
    ports:
      - 9090:9090
    command:
      - '--storage.tsdb.retention.time=2y'
      - '--storage.tsdb.path=/tsdb/'
      - '--web.enable-admin-api'
      - '--config.file=/etc/prometheus/prometheus.yaml'


[...]
  mqtt-exporter:
    image: kpetrem/mqtt-exporter
    container_name: shelly-mqtt-exporter
    ports:
      - 9093:9093
    environment:
      MQTT_ADDRESS: mqtt5
      MQTT_USERNAME: NOOPE
      MQTT_PASSWORD: NOOPE
      MQTT_EXPOSE_CLIENT_ID: true
      MQTT_TOPIC: shellies/+/status/#
      PROMETHEUS_PREFIX: shelly_
      PROMETHEUS_PORT: 9090
    restart: unless-stopped

prometheus.yaml

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
[...]
  - job_name: "shelly"
    static_configs:
      - targets: ['shelly-mqtt-exporter:9093']

crash loop with google coral metric

The container go in a crash loop if frigate push the google coral's metric to the mqtt server

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
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 342, 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 297, in expose_metrics
    _parse_metrics(payload, topic, userdata["client_id"])
  File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 128, in _parse_metrics
    _parse_metrics(value, topic, client_id, f"{prefix}{metric}_")
  File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 128, in _parse_metrics
    _parse_metrics(value, topic, client_id, f"{prefix}{metric}_")
  File "/opt/mqtt-exporter/mqtt_exporter/main.py", line 145, 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_cpu_usages_%Cpu:_mem

ValueError: Invalid metric name with '/'

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

Request to Publish Python Package on PyPI or Provide Linux Executable Release

Hi @kpetremann,

Thanks for the incredible exporter. I noticed that although you've provided docker images for easy deployment, there isn't a Python package available on PyPI or Linux executable for the convenient standalone installation.

Would it be possible to you to publish the exporter as a Python package on PyPI? or provide a standalone executables. This would help a lot, Thanks.

Once unavailable always unavailable even after becoming available in zigbee2mqtt

Describe the bug
Devices that were marked as unavailable by zigbee2mqtt never get available once zigbee2mqtt deems them available.

If the bug is related to parsing, please provide the original MQTT message.

To Reproduce
Steps to reproduce the behavior:

  1. Let a device be declared as unavailable in zigbee2mqtt.
  2. Verify that exporter correctly shows it as unavailable (0).
  3. Make the device be declared as available in zigbee2mqtt.
  4. Verify that exporter incorrectly does not handle the availability and continues to report it as unavailable indefinitely (0).

Expected behavior
The exporter should handle unavailable-to-available and correctly report it be available (1).

Screenshots

zigbee2mqtt_zigbee_availability{topic="zigbee2mqtt_Isabel's room multi sensor"} 0.0

Screenshot 2023-03-01 at 12 03 18

Attach additional labels from message user properties

Describe the solution you'd like
In MQTTv5 it is possible to attach "user properties" to each message, which is simply a string=>string dictionary.
It would be very cool if these properties could be added as labels on the associated metric either instead of the topic label, or in addition to it.

Additional context
I have several devices that publish several metrics. Currently I encode device information (such as which room and which floor it is in) in the device name, which then becomes part of the topic name. As a result I have topics with names like homely/smoke_alarm_basement_hallway/networklinkstrength with a single value.
It's probably possible to do some relabeling tricks to extract that information out to separate labels when ingesting into prometheus, but it would be so much easier if mqtt-exporter would just set the labels from user properties instead.

If this sounds like a good idea, and nobody beats me to it, I might attempt a PR for it.

ZIGBEE2MQTT_AVAILABILITY not working

Hi πŸ‘‹πŸΌ

I deployed this and I can see metrics coming thru but it seems like ZIGBEE2MQTT_AVAILABILITY=True is not working. I actually still see the _state metrics.

# HELP zigbee2mqtt_state metric generated from MQTT message.
# TYPE zigbee2mqtt_state gauge
zigbee2mqtt_state{topic="zigbee2mqtt_Basement - Back Yard - Door Sensor"} 0.0
zigbee2mqtt_state{topic="zigbee2mqtt_Basement - Door Sensor"} 0.0

image

zigbee2mqtt: Device renames

When renaming a device in zigbee2mqtt, the old device name still continues to exist in the exported metrics until mqtt-exporter is restarted, causing 'stuck' metrics. It would be nice to handle the rename message that zigbee2mqtt sends in some way to clear the old metric.

topic: zigbee2mqtt/bridge/response/device/rename
{
  "data": {
    "from": "socket/foo",
    "homeassistant_rename": false,
    "to": "socket/bar"
  },
  "status": "ok",
  "transaction": "tt7m3-3"
}
curl http://mqtt-exporter/

...
zigbee2mqtt_zigbee_availability{topic="zigbee2mqtt_socket_foo"} 1.0
zigbee2mqtt_zigbee_availability{topic="zigbee2mqtt_socket_bar"} 1.0
...
zigbee2mqtt_state{topic="zigbee2mqtt_socket_foo"} 1.0
zigbee2mqtt_state{topic="zigbee2mqtt_socket_bar"} 1.0
...etc

exporter does not produce any device metric

I have tried the exporter in my k8s setup. But it does not produce any device metrics.

This is the zigbee2mqtt log:

Info 2022-05-26 21:58:11MQTT publish: topic 'zigbee2mqtt/living_room/tv_left/plug', payload '{"current":0.11,"energy":287.04,"last_seen":"2022-05-26T19:58:11.525Z","linkquality":162,"power":17,"state":"ON","voltage":239}'
Info 2022-05-26 21:58:17MQTT publish: topic 'zigbee2mqtt/living_room/cabinet/light', payload '{"last_seen":"2022-05-26T19:58:17.361Z","linkquality":27,"state":"ON","update":{"state":"idle"},"update_available":false}'
Info 2022-05-26 21:58:17MQTT publish: topic 'zigbee2mqtt/living_room/tv_left/plug', payload '{"current":0.11,"energy":287.04,"last_seen":"2022-05-26T19:58:17.519Z","linkquality":162,"power":17,"state":"ON","voltage":239}'

This is the container log:

INFO:mqtt-exporter:listening to "zigbee2mqtt"  

This is the container output:

/ # export
export CHART_1653595418_MQTT_EXPORTER_PORT='tcp://10.43.36.6:9000'
export CHART_1653595418_MQTT_EXPORTER_PORT_9000_TCP='tcp://10.43.36.6:9000'
export CHART_1653595418_MQTT_EXPORTER_PORT_9000_TCP_ADDR='10.43.36.6'
export CHART_1653595418_MQTT_EXPORTER_PORT_9000_TCP_PORT='9000'
export CHART_1653595418_MQTT_EXPORTER_PORT_9000_TCP_PROTO='tcp'
export CHART_1653595418_MQTT_EXPORTER_SERVICE_HOST='10.43.36.6'
export CHART_1653595418_MQTT_EXPORTER_SERVICE_PORT='9000'
export CHART_1653595418_MQTT_EXPORTER_SERVICE_PORT_METRICS='9000'
export GPG_KEY='E3FF2839C048B25C084DEBE9B26995E310250568'
export HOME='/root'
export HOSTNAME='chart-1653595418-mqtt-exporter-855c5d668d-qdcrg'
export KUBERNETES_PORT='tcp://10.43.0.1:443'
export KUBERNETES_PORT_443_TCP='tcp://10.43.0.1:443'
export KUBERNETES_PORT_443_TCP_ADDR='10.43.0.1'
export KUBERNETES_PORT_443_TCP_PORT='443'
export KUBERNETES_PORT_443_TCP_PROTO='tcp'
export KUBERNETES_SERVICE_HOST='10.43.0.1'
export KUBERNETES_SERVICE_PORT='443'
export KUBERNETES_SERVICE_PORT_HTTPS='443'
export LANG='C.UTF-8'
export LOG_LEVEL='DEBUG'
export MQTT_ADDRESS='mosquitto.hass.svc.cluster.local'
export MQTT_KEEPALIVE='60'
export MQTT_PORT='1883'
export MQTT_TOPIC='zigbee2mqtt'
export PATH='/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
export PROMETHEUS_PORT='9000'
export PROMETHEUS_PREFIX='mqtt_'
export PWD='/'
export PYTHON_GET_PIP_SHA256='e235c437e5c7d7524fbce3880ca39b917a73dc565e0c813465b7a7a329bb279a'
export PYTHON_GET_PIP_URL='https://github.com/pypa/get-pip/raw/38e54e5de07c66e875c11a1ebbdb938854625dd8/public/get-pip.py'
export PYTHON_PIP_VERSION='22.0.4'
export PYTHON_SETUPTOOLS_VERSION='58.1.0'
export PYTHON_VERSION='3.9.12'
export SHLVL='2'
export TERM='xterm'
export TOPIC_LABEL='topic'
export TZ='UTC'
export ZIGBEE2MQTT_AVAILABILITY='True'
/ # cd /tmp/
/tmp # wget 127.0.0.1:9000
Connecting to 127.0.0.1:9000 (127.0.0.1:9000)
saving to 'index.html'
index.html           100% |**********************************************************************************************************************************************************************************************|  1980  0:00:00 ETA
'index.html' saved
/tmp # cat index.html 
# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 347.0
python_gc_objects_collected_total{generation="1"} 7.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 42.0
python_gc_collections_total{generation="1"} 3.0
python_gc_collections_total{generation="2"} 0.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="9",patchlevel="12",version="3.9.12"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 2.3732224e+07
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.8264064e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.65359542076e+09
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.28
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 7.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP mqtt_message_total Counter of received messages
# TYPE mqtt_message_total counter

Btw. I have created a helm chart for your project:
k8s-at-home/charts#1584

HomeAssistant

Hi,
(Me again πŸ˜„ )

HomeAssistant can export all sensors to MQTT by using below (home assistant) configuration:

mqtt_statestream:
  base_topic: homeassistant
  publish_attributes: true
  publish_timestamps: true

The result seems quite universal:
image

image

It lives under:
homeassistant/sensor/NAME, for example homeassistant/sensor/fridge_plug_voltage

image

Exporter does not find topic

My Tasmota devices are displayed and the values arrive as well.
But I am currently still trying to get the topics of my ESP01.
With MQTT-fx I could verify that the ESP really sends something and the topic is present.

The topics look like this:
"dht/livingroom/TEMPERATURE".
"dht/livingroom/HUMIDITY"

and send data like: '20.0'.

But the topics do not show up.
I'm starting to feel like I'm missing something obvious.

support client_id

it would be helpful to see the client_id...

The underlying python module seems to support that.

// The client() object creates an MQTT client. It takes 4 parameters which are optional:

client(client_id="", clean_session=True, userdata=None, protocol=MQTTv311, transport="tcp")

LOG_LEVEL

Hello, and I love your image!!

Was wondering what the level options for LOG_LEVEL are? I was looking for scraping everything from my broker, kinda like verbose. I didnt look hard enough in your code but I tried to find how to export basically #. thank you! and great app

Doesn't support Shelly 3EM format very well

Hello there,

my understanding from trying to use this to push 6 different power measurements from 2 Shelly 3EM devices, is that there's no way to either sum, or differentiate the three phases' measurements.

This is what one Shelly 3EM sends as MQTT topics:

shellies/shelly-deviceid1234/emeter/0/power
shellies/shelly-deviceid1234/emeter/0/pf
shellies/shelly-deviceid1234/emeter/0/current
shellies/shelly-deviceid1234/emeter/0/voltage
shellies/shelly-deviceid1234/emeter/0/total
shellies/shelly-deviceid1234/emeter/0/total_returned
shellies/shelly-deviceid1234/emeter/1/power
shellies/shelly-deviceid1234/emeter/1/pf
shellies/shelly-deviceid1234/emeter/1/current
shellies/shelly-deviceid1234/emeter/1/voltage
shellies/shelly-deviceid1234/emeter/1/total
shellies/shelly-deviceid1234/emeter/1/total_returned
shellies/shelly-deviceid1234/emeter/2/power
shellies/shelly-deviceid1234/emeter/2/pf
shellies/shelly-deviceid1234/emeter/2/current
shellies/shelly-deviceid1234/emeter/2/voltage
shellies/shelly-deviceid1234/emeter/2/total
shellies/shelly-deviceid1234/emeter/2/total_returned

As you can see, it reports 3 different e(nergy)meters, each with separate power, power factor (pf), current, voltage, and total energy, and total energy returned.

I haven't found a way to report on those separately, and as of now, only get a single mqtt_total that only contains the latter value.

Is there a way to configure mqtt-explorer to report on these separately? Or could this be allowed with a new configuration setting?

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.