Send metrics to an MQTT broker.


  • mosquitto
  • Python ssl module (and Python >= 2.7)

In order for this to do something useful, you'll need an MQTT broker (e.g. mosquitto and a diamond.conf containing something along these lines:

    handlers = diamond.handler.mqtt.MQTTHandler

    host = address-of-mqtt-broker  (default: localhost)
    port = 1883         (default: 1883; with tls, default: 8883)
    qos = 0             (default: 0)

    # If False, do not include timestamp in the MQTT payload
    # i.e. just the metric number
    timestamp = True

    # Optional topic-prefix to prepend to metrics en-route to
    # MQTT broker
    prefix = some/pre/fix       (default: "")

    # If you want to connect to your MQTT broker with TLS, you'll have
    # to set the following four parameters
    tls = True          (default: False)
    cafile =        /path/to/ca/cert.pem
    certfile =      /path/to/certificate.pem
    keyfile =       /path/to/key.pem

Test by launching an MQTT subscribe, e.g.:

    mosquitto_sub  -v -t 'servers/#'

or mosquitto_sub -v -t 'some/pre/fix/#'

To Graphite

You may be interested in mqtt2graphite which subscribes to an MQTT broker and sends metrics off to Graphite.


  • This handler sets a last will and testament, so that the broker publishes its death at a topic called clients/diamond/
  • Support for reconnecting to a broker is implemented and ought to work.


Setting Default Description Type
get_default_config_help get_default_config_help
server_error_interval 120 How frequently to send repeated server errors int