Skip to content

Mosquitto

Auto-Detection
Exporter Metrics

Glouton automatically detects Mosquitto when it is running on the monitored host.

Detailed Mosquitto metrics are available through the third-party sapcc/mosquitto-exporter.

  • Mosquitto MQTT broker installed and running
  • Glouton agent installed on the same host
  • Go toolchain (if building from source) or access to GitHub releases

No special configuration is required on the Mosquitto side. The exporter subscribes to the MQTT $SYS/# topics, which Mosquitto publishes by default with broker statistics.

Verify that Mosquitto is running and the $SYS topics are available:

Terminal window
mosquitto_sub -t '$SYS/#' -C 5

Download the latest release from the mosquitto-exporter releases page, or install with Go:

Terminal window
go install github.com/sapcc/mosquitto-exporter@latest

Start the exporter:

Terminal window
mosquitto-exporter --endpoint tcp://localhost:1883

The exporter listens on port 9234 by default. Verify it is working:

Terminal window
curl http://localhost:9234/metrics

For production use, create a systemd service unit to manage the exporter process.

Terminal window
sudo tee /etc/glouton/conf.d/99-mosquitto.conf > /dev/null << 'EOF'
metric:
prometheus:
targets:
- url: "http://localhost:9234/metrics"
name: "mosquitto"
allow_metrics:
- "mosquitto_clients_connected"
- "mosquitto_messages_received_total"
- "mosquitto_messages_sent_total"
- "mosquitto_clients_total"
- "mosquitto_bytes_received_total"
- "mosquitto_bytes_sent_total"
EOF
Metric Description
mosquitto_clients_connected Number of currently connected clients
mosquitto_messages_received_total Total number of messages received by the broker
mosquitto_messages_sent_total Total number of messages sent by the broker
mosquitto_clients_total Total number of active and inactive clients
mosquitto_bytes_received_total Total bytes received by the broker
mosquitto_bytes_sent_total Total bytes sent by the broker