Subscribe to MQTT topics and push to Graphite's Carbon server
Python Shell
Switch branches/tags
Nothing to show
Latest commit 3533ea6 Jun 30, 2017 @jpmens jpmens Merge pull request #11 from adnidor/master
enable setting the carbon key to a value combining a constant string and the MQTT topic


This program subscribes to any number of MQTT topics, extracts a value from the messages' payload and sends that off to Graphite via Carbon over a UDP socket.

Values in the payload can be simple numbers (92, 12.7) or JSON strings. In the latter case, all JSON names/keys are extracted and if their values are numeric, these are then sent off to Carbon (see example below)


Installation and Configuration

  • Configure the mqtt2graphite init script
pip install git+
./ mqtt.hostname


  • Edit the mqtt.hostname.conf file
  • Run or add this cmd supervisord -c /etc/supervisord.conf in your /etc/rc.local

Handling numeric payloads

mqtt2graphite assumes topics defined as "n" in the map file contain a simple number (integer or float), published thusly:

mosquitto_pub  -t test/jp/j1 -m '69'

Handling JSON payloads

mosquitto_pub  -t test/jp/j2 -m '{ "size":69,"temp": 89.3, "gas": " 88", "name": "JP Mens" }'

produces the following Carbon keys 88.000000 1363169282 89.300000 1363169282 69.000000 1363169282


A lot.

  • Add configuration file in which we specify username/password and TLS certificates.
  • I'm not experienced enough with high volume of messages, so this should maybe transmit to Carbon via StatsD?