MQTT subscriber that pumps data into InfluxDB.
Pronounced 'm-cutey' :)
- MQTT 3.1.1 supported, TLS, username/password
- InfluxDB with TLS, username/password
- Consume MQTT messages and inspect (
watch
) orforward
with the following abilities:- Filter messages with AND + OR
- Receive MQTT messages and write into InfluxDB, with the following abilities:
- Add tags based on MQTT fields (when MQTT payload is JSON)
- Geohash support (applicable when consuming MQTT messages from Owntracks
- Includes
docker-compose.yaml
to get a full setup up and running!
Configuration is handled through a config.yaml
file. The following example reads as:
- Setup four workers for incoming MQTT messages
- Consume message from MQTT server
tcp://localhost:1883
with the client ID ofmqti
- When a MQTT message is consumed from the
temperature
topic, send write requests to InfluxDB serverhttp://localhost:8086
, into theiot
database as measurementtemperature
---
mqti:
workers: 4
mqtt:
host: "localhost"
port: "1883"
client_id: "mqti"
influxdb:
host: "localhost"
port: "8086"
mappings:
- mqtt:
topic: "temperature"
influxdb:
database: "iot"
measurement: "temperature"
go get github.com/ashmckenzie/go-mqti/mqti
or download a release:
github.com/ashmckenzie/go-mqti/releases
- Ensure you have a
config.yaml
setup (see above)
$GOPATH/bin/mqti watch
$GOPATH/bin/mqti forward
See the getting started section of a Golang Melbourne presentation for a full demonstration :)
MQTT subscriber that pumps data into InfluxDB
Usage:
mqti [flags]
mqti [command]
Available Commands:
forward Forward MQTT messages on to InfluxDB
watch Watch MQTT messages
help Help about any command
Flags:
--config string config file (default is config.yaml)
--debug enable debugging
-h, --help help for mqti
-v, --version show version
Use "mqti [command] --help" for more information about a command.
make
- Tests
- Document externals
- Fully document mungers
- Leverage viper's default values
- github.com/eclipse/paho.mqtt.golang
- github.com/influxdata/influxdb/client
- github.com/spf13/cobra
- github.com/spf13/viper
- github.com/Sirupsen/logrus
MIT License
Copyright (c) 2017 Ash McKenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.