MQTT Data Exporter for Prometheus

Made to read all messages with values that may be converted to float number and expose it to Prometheus database.

mqtt data exporter with grafana


Run my prebuilt image from docker hub

USE_ENV_VARS=1 is required to run with variables from envieronment. If you set up MQTTHOST then you must also set up MQTTPORT, MQTTUSER, MQTTPASS. Another variables not required.

docker run --name mqttde_container -d \
  -e USE_ENV_VARS=1 \
  -e \
  -e MQTTPORT=1883 \
  -e MQTTUSER=bus \
  -e MQTTPASS=myultrapassword \
  -e EXPOPORT=9021 \
  -p 9021:9021 iam21h/mqtt-data-exporter

You can find my prebuilt images in docker hub.

Build docker image yourself

Clone repository and run build command, after that you can run your new image.

git clone
docker build -t mqtt-data-exporter-myown .

Hard way

Install python 3, pip3 and requirements

git clone
cd mqtt-data-exporter
apt install python3 python3-pip
pip3 install --no-cache-dir -r requirements.txt

Configure and rename it to

mqttCreds = { 
    "port": 1883,
    "auth": { "username":"bus", "password":"myultrapassword" }

# listening port. yes, 21 is in my nick :)
exporterPort = 9021

# seconds before reconnection
# I'm sure 60 is enought
reconnectTime = 60

Start python3

Now you have own parametric monitoring from MQTT bus.


Copyright © Vladimir Smagin, 2018

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see