Dashboard di monitoraggio per tutta l'infrastruttura
Prometheus raccoglie metriche, Grafana le visualizza. Insieme formano lo stack di monitoraggio più diffuso per homelab e datacenter.
1. Installare Prometheus
apt install prometheus -y
systemctl enable --now prometheus
2. Configurare target (/etc/prometheus/prometheus.yml)
scrape_configs:
- job_name: "node"
static_configs:
- targets:
- "192.168.1.81:9100"
- "192.168.1.90:9100"
- "192.168.1.108:9100"
- "192.168.1.92:9100"
3. Node Exporter su ogni server
apt install prometheus-node-exporter -y
systemctl enable --now prometheus-node-exporter
4. Installare Grafana
apt install -y apt-transport-https software-properties-common
wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key
echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" > /etc/apt/sources.list.d/grafana.list
apt update && apt install grafana -y
systemctl enable --now grafana-server
5. Collegare Prometheus a Grafana
Accedere a Grafana su porta 3000, aggiungere data source Prometheus (http://localhost:9090), importare dashboard ID 1860 (Node Exporter Full).
6. Alert
# In prometheus.yml, aggiungere alerting rules
rule_files:
- "alerts.yml"
# alerts.yml
groups:
- name: node
rules:
- alert: HighCPU
expr: 100 - (avg by(instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80
for: 5m
Con Prometheus + Grafana hai visibilità completa su CPU, RAM, disco, rete e temperature di tutti i server del homelab.