setup the best light system matrix server with Telegraf + InfluxDB + Grafana
TL;DR
Setup Telegraf on every server you want to collect system matrix from then connect to the central server having InfluxDB, then connect with Grafana to view.
๐ฅ๏ธ 1. Central Server Setup (InfluxDB + Grafana)
sudo apt update
sudo apt install influxdb influxdb-client -y
sudo systemctl enable influxdb
sudo systemctl start influxdb
Check status:
systemctl status influxdb
Create Database for Metrics
influx
CREATE DATABASE telegraf
CREATE USER telegraf WITH PASSWORD 'yourpassword'
GRANT ALL ON telegraf TO telegraf
EXIT
Install Grafana
sudo apt-get install -y apt-transport-https software-properties-common
sudo mkdir -p /etc/apt/keyrings/
wget -q -O - https://packages.grafana.com/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/grafana.gpg
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install grafana -y
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
Access Grafana:
๐ http://your-central-server:3000
(Default login: admin / admin)
*Can setup a domain using caddy
๐ฅ๏ธ 2. Telegraf Setup on Each Server
sudo apt update
sudo apt install telegraf -y
sudo systemctl enable telegraf๐ Minimal Telegraf Config (/etc/telegraf/telegraf.conf)
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
debug = false
quiet = false
logfile = ""
###############################################################################
#OUTPUTS
###############################################################################
[[outputs.influxdb]]
urls = ["http://YOUR_CENTRAL_SERVER_IP:8086"]
database = "telegraf"
username = "telegraf"
password = "yourpassword"
###############################################################################
#INPUTS
###############################################################################
#CPU metrics
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = true
#Memory usage
[[inputs.mem]]
#Disk usage
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "overlay"]
#Network stats
[[inputs.net]]
#System load & uptime
[[inputs.system]]Save file โ Restart Telegraf then Verify logs
sudo systemctl restart telegraf
sudo journalctl -u telegraf -fSuccessfully wrote metrics - should be the output.