8000 GitHub - archlevel/mqtt-exporter: Simple generic MQTT exporter for IoT
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

archlevel/mqtt-exporter

 
 

Repository files navigation

build Codacy Badge Maintainability Code style: black License: MIT

MQTT-exporter

Description

Simple and generic Prometheus exporter for MQTT. Tested with Mosquitto MQTT and Xiaomi sensors.

It exposes metrics from MQTT message out of the box (you just need to specify the target if not on localhost).

MQTT-exporter expects a topic and a JSON payload.

Example

topic 'zigbee2mqtt/0x00157d00032b1234', payload '{"temperature":26.24,"humidity":45.37}'

will be converted as:

temperature{topic="zigbee2mqtt_0x00157d00032b1234"} 25.24
humidity{topic="zigbee2mqtt_0x00157d00032b1234"} 45.37

Configuration

Parameters are passed using environment variables.

The list of parameters are:

  • LOG_LEVEL: Logging level (default: INFO)
  • MQTT_ADDRESS: IP or hostname of MQTT broker (default: 127.0.0.1)
  • MQTT_PORT: TCP port of MQTT broker (default: 1883)
  • MQTT_KEEPALIVE: Keep alive interval to maintain connection with MQTT broker (default: 60)
  • MQTT_USERNAME: Username which should be used to authenticate against the MQTT broker (default: None)
  • MQTT_PASSWORD: Password which should be used to authenticate against the MQTT broker (default: None)
  • PROMETHEUS_PORT: HTTP server PORT to expose Prometheus metrics (default: 9000)
  • PROMETHEUS_PREFIX: Prefix added to the metric name, example: mqtt_temperature (default: mqtt_)
  • TOPIC_LABEL: Define the Prometheus label for the topic, example temperature{topic="device1"} (default: topic)

Deployment

Using Docker

docker run -it -p 9000:9000 -e "MQTT_ADDRESS=192.168.0.1" kpetrem/mqtt-exporter

Using Docker Compose

version: "3"
services:
  mqtt-exporter:
    image: kpetrem/mqtt-exporter
    ports:
      - 9000:9000
    environment:
      - MQTT_ADDRESS=192.168.0.1

Using Python

pip install -r requirements/base.txt
MQTT_ADDRESS=192.168.0.1 python exporter.py

About

Simple generic MQTT exporter for IoT

Resources

License

Stars

Watchers

Forks

Releases

< 33B7 div class="text-small color-fg-muted">No releases published

Packages

No packages published

Languages

  • Python 93.0%
  • Dockerfile 7.0%
0