Guide

Prometheus, Grafana e Alertmanager su un solo VPS: la guida weekend senza Kubernetes

Monitoraggio self-hosted su un singolo VPS Ubuntu 24.04: Prometheus, node_exporter, Grafana e un alert quando il disco supera l'80%.

Redazione UptimeMag · 31 ottobre 2026 · 4 minuti di lettura

Prometheus, Grafana e Alertmanager su un solo VPS: la guida weekend senza Kubernetes

Chi gestisce due o tre VPS non ha bisogno di un cluster Kubernetes con Prometheus Operator per sapere se un disco sta per riempirsi. Bastano quattro binari su una singola macchina Ubuntu 24.04, un file di configurazione per servizio e un pomeriggio di tempo. Questa guida copre l'installazione di Prometheus, node_exporter, Grafana e Alertmanager su un solo server, con una regola che avvisa via email o Telegram quando lo spazio disco supera l'80%.

Versioni usate in questa guida

Le versioni cambiano nel tempo: prima di lanciare i comandi, controllate sempre il numero più recente sulla pagina ufficiale, perché gli URL di download contengono la versione nel nome del file.

Componente Versione Data rilascio Fonte
Prometheus 3.15.1 (stable) 21 ottobre 2026 prometheus.io/download
node_exporter 1.12.1 14 luglio 2026 prometheus.io/download
Alertmanager 0.34.2 29 ottobre 2026 prometheus.io/download
Grafana OSS 13.3.0 27 ottobre 2026 grafana.com/grafana/download

Oltre alla 3.15.1, Prometheus pubblica anche una release LTS, la 3.13.5, e una pre-release 3.16.0-rc.2: per un server di produzione conviene restare sulla stable o sulla LTS, non sulla rc.

Passo 1: node_exporter, la sonda sul sistema operativo

Creare l'utente di sistema e scaricare il binario:

sudo useradd --no-create-home --shell /bin/false node_exporter
cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.12.1/node_exporter-1.12.1.linux-amd64.tar.gz
tar xvfz node_exporter-1.12.1.linux-amd64.tar.gz
sudo mv node_exporter-1.12.1.linux-amd64/node_exporter /usr/local/bin/
sudo chown root:root /usr/local/bin/node_exporter

Unit systemd in /etc/systemd/system/node_exporter.service:

[Unit]
Description=Prometheus Node Exporter
After=network.target

[Service]
Type=simple
User=node_exporter
ExecStart=/usr/local/bin/node_exporter
Restart=always

[Install]
WantedBy=multi-user.target

Attivazione:

sudo systemctl daemon-reload
sudo systemctl enable --now node_exporter
curl -s http://localhost:9100/metrics | head

Se compaiono righe che iniziano con node_, l'exporter funziona. Porta predefinita: 9100.

Passo 2: Prometheus

cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v3.15.1/prometheus-3.15.1.linux-amd64.tar.gz
tar xvf prometheus-3.15.1.linux-amd64.tar.gz
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo mv prometheus-3.15.1.linux-amd64/prometheus /usr/local/bin/
sudo mv prometheus-3.15.1.linux-amd64/promtool /usr/local/bin/
sudo mv prometheus-3.15.1.linux-amd64/consoles /etc/prometheus/
sudo mv prometheus-3.15.1.linux-amd64/console_libraries /etc/prometheus/
sudo useradd --no-create-home --shell /bin/false prometheus
sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus

File /etc/prometheus/prometheus.yml:

global:
 scrape_interval: 15s

rule_files:
 - "/etc/prometheus/alert.rules.yml"

alerting:
 alertmanagers:
 - static_configs:
 - targets: ["localhost:9093"]

scrape_configs:
 - job_name: "node"
 static_configs:
 - targets: ["localhost:9100"]

Unit systemd in /etc/systemd/system/prometheus.service:

[Unit]
Description=Prometheus
After=network.target

[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/bin/prometheus \
 --config.file=/etc/prometheus/prometheus.yml \
 --storage.tsdb.path=/var/lib/prometheus \
 --web.listen-address=0.0.0.0:9090
Restart=always

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now prometheus

Verifica su http://IP-DEL-VPS:9090/targets: il target node deve risultare UP.

Passo 3: la regola per il disco oltre l'80%

File /etc/prometheus/alert.rules.yml:

groups:
 - name: disco
 rules:
 - alert: DiscoQuasiPieno
 expr: (1 - (node_filesystem_avail_bytes{mountpoint="/",fstype!="tmpfs"} / node_filesystem_size_bytes{mountpoint="/",fstype!="tmpfs"})) * 100 > 80
 for: 5m
 labels:
 severity: warning
 annotations:
 summary: "Disco oltre l'80% su {{ $labels.instance }}"
 description: "Uso disco al {{ $value | printf \"%.1f\" }}% sul mountpoint /."

Ricaricare senza riavviare il servizio:

sudo promtool check rules /etc/prometheus/alert.rules.yml
curl -X POST http://localhost:9090/-/reload

Passo 4: Alertmanager e la notifica

cd /tmp
wget https://github.com/prometheus/alertmanager/releases/download/v0.34.2/alertmanager-0.34.2.linux-amd64.tar.gz
tar xvf alertmanager-0.34.2.linux-amd64.tar.gz
sudo mkdir -p /etc/alertmanager /var/lib/alertmanager
sudo mv alertmanager-0.34.2.linux-amd64/alertmanager /usr/local/bin/
sudo mv alertmanager-0.34.2.linux-amd64/amtool /usr/local/bin/
sudo useradd --no-create-home --shell /bin/false alertmanager
sudo chown -R alertmanager:alertmanager /etc/alertmanager /var/lib/alertmanager

Notifica via email

File /etc/alertmanager/alertmanager.yml:

global:
 smtp_smarthost: 'smtp.vostroprovidermail.it:587'
 smtp_from: 'alert@vostrodominio.it'
 smtp_auth_username: 'alert@vostrodominio.it'
 smtp_auth_password: 'LAVOSTRAPASSWORD'

route:
 receiver: email-sistemista

receivers:
 - name: email-sistemista
 email_configs:
 - to: 'voi@vostrodominio.it'
 send_resolved: true

Notifica via Telegram

In alternativa all'email, sostituite il receiver con:

receivers:
 - name: telegram-sistemista
 telegram_configs:
 - bot_token: 'IL_TOKEN_DEL_BOT'
 chat_id: -1001234567890
 send_resolved: true
 parse_mode: 'HTML'

Il bot si crea da Telegram parlando con @BotFather; il chat_id si ottiene inviando un messaggio al bot e leggendo https://api.telegram.org/bot<TOKEN>/getUpdates.

Unit systemd in /etc/systemd/system/alertmanager.service:

[Unit]
Description=Alertmanager
After=network.target

[Service]
Type=simple
User=alertmanager
ExecStart=/usr/local/bin/alertmanager \
 --config.file=/etc/alertmanager/alertmanager.yml \
 --storage.path=/var/lib/alertmanager
Restart=always

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now alertmanager

Porta predefinita Alertmanager: 9093.

Passo 5: Grafana e la dashboard CPU/RAM/disco/rete

Grafana pubblica un repository APT ufficiale; i comandi riportati sono quelli della documentazione ufficiale grafana.com per Debian e Ubuntu:

sudo apt-get install -y apt-transport-https wget gnupg
sudo mkdir -p /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/grafana.asc https://apt.grafana.com/gpg-full.key
sudo chmod 644 /etc/apt/keyrings/grafana.asc
echo "deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install grafana
sudo systemctl enable --now grafana-server

Con questo metodo Grafana automatically updates when you run apt-get update, a differenza del pacchetto .deb scaricato a mano, che va aggiornato manualmente a ogni nuova versione.

Login su http://IP-DEL-VPS:3000 con utente admin e password admin (richiesta al primo accesso). Aggiungere Prometheus come data source puntando a http://localhost:9090. Per la dashboard CPU/RAM/disco/rete non serve costruirla da zero: da "Dashboards → Import" si importa una dashboard pubblica compatibile con le metriche di node_exporter inserendo il suo ID numerico dal catalogo grafana.com/dashboards e selezionando come data source quello appena creato.

Verifica finale: generare un alert di prova

Per controllare che la catena Prometheus → Alertmanager → notifica funzioni senza aspettare che il disco si riempia davvero, si può inviare un alert fittizio direttamente ad Alertmanager con amtool:

amtool alert add alertname=DiscoQuasiPieno instance=test-vps severity=warning --alertmanager.url=http://localhost:9093

Entro pochi secondi deve arrivare l'email o il messaggio Telegram. Per vedere gli alert attivi in coda:

amtool alert query --alertmanager.url=http://localhost:9093

Se la notifica non arriva, il primo punto da controllare è il log del servizio: sudo journalctl -u alertmanager -f.

Nota sulla sicurezza

Le porte 9090, 9093 e 9100 non hanno autenticazione di default. Su un VPS esposto su internet vanno filtrate con ufw o iptables, lasciando l'accesso solo da localhost o da una VPN, ed esponendo pubblicamente solo la porta 3000 di Grafana dietro un reverse proxy con TLS.

Testo redatto con il supporto dell'intelligenza artificiale e verificato dalla redazione (AI Act, art. 50).