influxDB 1.8.x / Telegraf 1.20.x / Grafana 8.2.x auf Raspian Buster

Auf dem Weg meinen ioBroker auf einem Raspberry Pi 4 neu aufzusetzten habe ich mich auch damit befasst influxDB (1.8.x) und Grafana (8.2.x) zu installieren. Zum Zeitpunkt gibt es bereits die Version 2.x von influxDB allerdings nur für 64bit und das aktuelle Raspbian läuft weiterhin mit 32bit. Natürlich gibt es einige Tutorials im Internet allerdings keines mit der jeweils aktuellen Version.
influxDB installieren
Es sind leichte Anpassung des Codes aus der originalen Dokumentation notwendig:
curl -s https://repos.influxdata.com/influxdb.key | gpg --dearmor > /etc/apt/trusted.gpg.d/influxdb.gpg export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc) echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" > /etc/apt/sources.list.d/influxdb.list
curl -fsSL https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null export DISTRIB_CODENAME=$(lsb_release -sc) echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/debian ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
Nun das ganze noch installieren:
sudo apt-get update && sudo apt install influxdb sudo systemctl unmask influxdb.service sudo systemctl start influxdb
Ich benötige einen Administrativen nutzer, einen Benutzer für ioBroker sowie eine dem User zugeordnetet Datenbank. Dazu benutze ich sudo influx
und tätige folgende Eingaben:
CREATE USER "admin" WITH PASSWORD '<adminpassword>' WITH ALL PRIVILEGES CREATE USER "iobroker_user" WITH PASSWORD '<userpassword>' WITH ALL PRIVILEGES CREATE DATABASE "iobroker_db" GRANT ALL ON "iobroker_db" TO "iobroker_user"
Da das System nur im lokalen Netzwerk läuft bzw. nur über VPN erreichbar sein wird kann ich die Datenbank für HTTP öffnen:
sudo nano /etc/influxdb/influxdb.conf
Dort nehme ich folgende Anpassungen vor:
[http] enabled = true bind-address = ":8086" auth-enabled = true log-enabled = true write-tracing = false pprof-enabled = false https-enabled = false https-certificate = "/etc/ssl/influxdb.pem"
Nun noch ein Neustart und influxDB läuft
sudo systemctl enable influxdb sudo systemctl restart influxdb
Telegraf
Die richtige Quelle habe ich bereits im Abschnitt influxDB definiert.
sudo apt-get update && sudo apt install telegraf sudo systemctl enable telegraf
influx -username "admin" -password "password"
CREATE DATABASE "telegraf" USE telegraf create user "telegrafuser" with password 'telegrafuserpassword' with all privileges grant all privileges on telegraf to telegrafuser create retention policy "4Weeks" on "telegraf" duration 4w replication 1 default exit
sudo nano /etc/telegraf/telegraf.conf
[[outputs.influxdb]] urls = ["http://127.0.0.1:8086"] database = "telegraf" username = "telegrafuser" password = "telegrafuserpassword"
sudo systemctl reload telegraf.service sudo systemctl status telegraf.service
An diesem Punkt beginnt Telegraf, Daten in die InfluxDB zu pushen. Hier ist ein schneller Weg, um zu überprüfen, ob etwas in die Datenbank geschrieben wurde.
influx -username "admin" -password "password"
use telegraf select * from system limit 5
Grafana
sudo apt-get install -y adduser libfontconfig1 wget https://dl.grafana.com/oss/release/grafana_8.2.1_armhf.deb sudo dpkg -i grafana_8.2.1_armhf.deb ### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd sudo /bin/systemctl daemon-reload sudo /bin/systemctl enable grafana-server ### You can start grafana-server by executing sudo /bin/systemctl start grafana-server
Quelle:
- https://docs.influxdata.com/influxdb/v1.8/introduction/install/
- https://grafana.com/grafana/download?edition=oss&pg=get&plcmt=selfmanaged-box1-cta1&platform=arm