A simple daemon for publishing MQTT data into statsd
Go to file
qingszhao 4e4794f512 fix tox python3 overrides
We want to default to running all tox environments under python 3, so
set the basepython value in each environment.

We do not want to specify a minor version number, because we do not
want to have to update the file every time we upgrade python.

We do not want to set the override once in testenv, because that
breaks the more specific versions used in default environments like
py35 and py36.

Change-Id: Ibe1df0814b0ab0b057d55e1d67286a164bb3dfae
2018-06-12 00:59:43 +08:00
doc/source Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
mqtt_statsd Fix usability around CLI 2017-04-03 22:59:11 -04:00
releasenotes Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
.coveragerc Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
.gitignore Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
.gitreview Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
.mailmap Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
.testr.conf Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
CONTRIBUTING.rst Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
HACKING.rst Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
LICENSE Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
MANIFEST.in Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
README.rst Initial commit 2017-04-03 16:55:47 -04:00
babel.cfg Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
requirements.txt Initial commit 2017-04-03 16:55:47 -04:00
setup.cfg Initial commit 2017-04-03 16:55:47 -04:00
setup.py Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
test-requirements.txt Initial Cookiecutter Commit. 2017-04-03 15:25:21 -04:00
tox.ini fix tox python3 overrides 2018-06-12 00:59:43 +08:00

README.rst

mqtt_statsd

As the name implies this a script to publish MQTT metrics into statsd. It was originally designed to handle metrics from the $SYS/ topics in the mosquitto broker, but the framework is generic enough that any MQTT topic can be used.

Installation

mqtt_statsd is available via pypi, so all you need to do is run:

pip install -U mqtt_statsd

to get mqtt_statsd on your system. If you need to use a development version of mqtt_statsd you can clone the repo and install it locally with:

git clone https://github.com/mtreinish/mqtt_statsd.git && pip install -e mqtt_statsd

which will install mqtt_statsd in your python environment in editable mode for local development.

Configuring mqtt_statsd

Before you run mqtt_statsd you have to create a yaml configuration file to tell mqtt_statsd how to connect to both the MQTT broker, and statsd. As well as which MQTT topics to subscribe to and how to populate statsd with the data it gets from that MQTT topic. For example:

statsd:
  hostname: localhost
  # port is optional, the default is shown
  port: 8125
  # prefix is optional, the default is shown
  prefix: mosquitto.stats
mqtt:
  hostname: localhost
  # port is optional, the default is shown
  port: 1883
  # keepalive is optional, the default is shown
  keepalive: 60
  # username is optional, there is no default
  username: foo
  # password is optional, there is no default. If username isn't set this
  # is ignored
  password: PASS
  # qos is optional, the default is shown
  qos: 0
  # websocket is optional, it defaults to False
  websocket: True
topics:
  # You can specify as many topics as you want, and mqtt_statsd will
  # listen to all of them
  - $SYS/broker/messages/publish/sent:
    statsd_topic: publish_messages_sent
    # statsd_type is optional, the default is shown. Valid options are
    # gague, counter, and timer
    statsd_type: gauge
  - $SYS/broker/clients/connected:
    statsd_topic: connected_clients

Running mqtt_statsd

Aftering installing and configuring mqtt_statsd running it is incredibly straightforward. Just call mqtt_statsd and it takes 1 mandatory argument, the path to the yaml config file. For example:

mqtt_statsd my_config_file.yaml