inuits/mqttgateway

Name: mqttgateway

Owner: Inuits

Description: Prometheus meets the Internet of Things

Created: 2018-05-01 11:45:20.0

Updated: 2018-05-05 10:08:00.0

Pushed: 2018-05-02 06:52:52.0

Homepage: null

Size: 7

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

MQTTGateway for Prometheus

A project that subscribes to MQTT queues and published prometheus metrics.

e: mqttgateway [<flags>]

s:
help                        Show context-sensitive help (also try
lp-long and --help-man).
web.listen-address=":9337"  Address on which to expose metrics and web
rface.
web.telemetry-path="/metrics"
                            Path under which to expose metrics.
mqtt.broker-address="tcp://localhost:1883"
                            Address of the MQTT broker.
mqtt.topic="prometheus/#"   MQTT topic to subscribe to
mqtt.prefix="prometheus"    MQTT topic prefix to remove when creating
ics
log.level="info"            Only log messages with the given severity or
e. Valid levels: [debug, info, warn, error, fatal]
log.format="logger:stderr"  Set the log target and format. Example:
ger:syslog?appname=bob&local=7" or "logger:stdout?json=true"
Installation

Requires go > 1.9

et -u github.com/inuits/mqttgateway
How does it work?

mqttgateway will connect to the MQTT broker at --mqtt.broker-address and listen to the topics specified by --mqtt.topic.

By default, it will listen to prometheus/#.

The format for the topics is as follow:

prefix/LABEL1/VALUE1/LABEL2/VALUE2/NAME

A topic prometheus/job/ESP8266/instance/livingroom/temperature_celcius would be converted to a metric temperature_celcius{job="ESP8266",instance="livingroom"}.

If labelnames differ for a same metric, then we invalidate existing metrics and only keep new ones. Then we issue a warning in the logs. You should avoid it.

Two other metrics are published, for each metric:

Security

This project does not support authentication yet but that is planned.

Example
squitto_pub -m 20.2 -t prometheus/job/ESP8266/instance/livingroom/temperature_celcius
rl -s http://127.0.0.1:9337/metrics|grep temperature_celcius|grep -v '#'
_temperature_celcius_last_pushed_timestamp{instance="livingroom",job="ESP8266"} 1.525185129171293e+09
_temperature_celcius_push_total{instance="livingroom",job="ESP8266"} 1
erature_celcius{instance="livingroom",job="ESP8266"} 20.2
A note about the prometheus config

If you use job and instance labels, please refer to the pushgateway exporter documentation.

TL;DR: you should set honor_labels: true in the scrape config.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.