This container runs Telegraf consuming MQTT messages posted by the various sensors and pushing the data into InfluxDB.
On your local machine you can replicate the MQTT -> Telegraf -> InfluxDB setup by running the following commands from within the telegraf subdirectory:
docker build . -t telegraf
docker network create telegraf
docker run -d --rm -p 1883:1883 -p 9001:9001 --name mqtt -v $PWD/../mqtt/mosquitto.conf:/mosquitto/config/mosquitto.conf --network telegraf eclipse-mosquitto
docker run -d --rm -p 8086:8086 --name influxdb -v influxdb:/var/lib/influxdb --network telegraf influxdb:1.8
docker run --network telegraf telegraf
Now you can now connect to the MQTT queue using MQTT Explorer and send test messages.
To cleanup:
docker stop mqtt
docker stop influxdb
docker network rm telegraf
In order to inspect or modify the data stored in the Influx database you can connect directly to the influxdb container and start the influx
CLI:
$ balena ssh <app-name> influxdb
? Select a device amazing-smoke (a36de3)
root@265d8274d16b:/# influx
Connected to http://localhost:8086 version 1.8.0
InfluxDB shell version: 1.8.0
In order to get human-readable dates use the precision rfc3339
command:
> precision rfc3339
> use weather
Using database weather
> show measurements
name: measurements
name
----
humidity
rain
temperature
water-temperature
wind-direction
wind-speed
To select the entries of a measurement:
> SELECT * FROM "water-temperature"
2021-06-18T06:05:05Z DS18B20 22.0625 sensors
...
To delete entries from a measurement use te DROP SERIES
query:
> DROP SERIES FROM "water-temperature"
- Telegraf configuration
- Telegraf troubleshooting
- Telegraf JSON input data format
- plugins