Prometheus exporter for Mosquitto MQTT broker metrics, written in Rust.
1.6K
A lightweight Prometheus exporter written in Rust that monitors Mosquitto broker $SYS metrics and exposes them via an HTTP endpoint.
154544 from "154544 seconds").tls:// prefix.Ensure you have the Rust toolchain installed.
cargo build --release
The application looks for a configuration file at /config.yml. If this file is missing, the exporter will fall back to a comprehensive set of built-in defaults. Example config.yml
metrics:
- topic: "$SYS/broker/uptime"
name: "mqtt_uptime_seconds"
help: "Total uptime of the broker in seconds"
- topic: "$SYS/broker/clients/connected"
name: "mqtt_clients_connected"
help: "Number of currently connected clients"
- topic: "$SYS/broker/load/bytes/received/1min"
name: "mqtt_load_bytes_received_1min"
help: "Average bytes received per minute over the last minute"
- topic: "$SYS/broker/messages/sent"
name: "mqtt_messages_sent_total"
help: "Total number of messages sent since startup"
You can configure the exporter via a .env file or system environment variables:
| Variable | Default | Description |
|---|---|---|
| MQTT_HOST | tcp://127.0.0.1 | Broker address (use tls:// for SSL/TLS) |
| MQTT_PORT | 1883 | Network port of the MQTT broker |
| MQTT_USER | - | MQTT Username (optional) |
| MQTT_PASS | - | Password (optional) |
| HTTP_PORT | 9090 | Port to serve Prometheus metrics on |
| LOGLEVEL | info | Logging verbosity (error, warn, info, debug) |
Run the compiled binary:
./mosquitto-prometheus-exporter
Access your metrics at: http://localhost:9090/metrics
Run the docker image:
docker run -ti -e "MQTT_HOST=tls://example.com" -e "MQTT_PORT=8883" -p "9090:9090" bpmbee/mosquitto-exporter:latest
Add the following job to your prometheus.yml configuration:
scrape_configs:
- job_name: 'mosquitto_exporter'
static_configs:
- targets: ['localhost:9090']
MIT / Apache-2.0
Content type
Image
Digest
sha256:2a940e3ea…
Size
4.1 MB
Last updated
5 months ago
docker pull bpmbee/mosquitto-exporter