Prometheus / Grafana
Prometheus + Grafana Installation auf Debian 12 (IP: 10.0.0.20)
Voraussetzungen
- Debian 12 Server mit statischer IP (z. B.
10.0.0.20
) - Root- oder Sudo-Zugriff
- Internetverbindung
- Optional: ein zweiter Server/Webserver für Node Exporter (z. B.
10.0.0.30
)
System aktualisieren
sudo apt update && sudo apt upgrade -y
Prometheus 2.53.5 installieren
Download und Entpacken
cd /opt sudo wget https://github.com/prometheus/prometheus/releases/download/v2.53.5/prometheus-2.53.5.linux-amd64.tar.gz sudo tar -xvf prometheus-2.53.5.linux-amd64.tar.gz sudo mv prometheus-2.53.5.linux-amd64 prometheus
Benutzer und Verzeichnisse erstellen
sudo useradd --no-create-home --shell /bin/false prometheus sudo mkdir -p /etc/prometheus /var/lib/prometheus
Binärdateien kopieren
cd /opt/prometheus sudo cp prometheus promtool /usr/local/bin/ sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
Konfiguration kopieren
sudo cp -r consoles/ console_libraries/ /etc/prometheus/ sudo cp prometheus.yml /etc/prometheus/ sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus
Prometheus konfigurieren
sudo nano /etc/prometheus/prometheus.yml
Beispiel-Inhalt:
global: scrape_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'webserver' static_configs: - targets: ['10.0.0.30:9100']
Systemd-Service für Prometheus erstellen
sudo nano /etc/systemd/system/prometheus.service
Inhalt:
[Unit] Description=Prometheus Monitoring Wants=network-online.target After=network-online.target [Service] User=prometheus Group=prometheus Type=simple ExecStart=/usr/local/bin/prometheus \ --config.file=/etc/prometheus/prometheus.yml \ --storage.tsdb.path=/var/lib/prometheus/ [Install] WantedBy=multi-user.target
Prometheus starten
sudo systemctl daemon-reexec sudo systemctl enable --now prometheus
Grafana installieren
Repository einrichten
sudo apt install -y software-properties-common sudo mkdir -p /etc/apt/keyrings sudo wget -q -O /etc/apt/keyrings/grafana.key https://packages.grafana.com/gpg.key echo "deb [signed-by=/etc/apt/keyrings/grafana.key] https://packages.grafana.com/oss/deb stable main" | \ sudo tee /etc/apt/sources.list.d/grafana.list sudo apt update
Grafana installieren
sudo apt install grafana -y sudo systemctl enable --now grafana-server
Webinterface: [1](http://10.0.0.20:3000)
Standard-Login: admin
/ admin
Grafana mit Prometheus verbinden
1. Im Browser öffnen: http://10.0.0.20:3000
2. Menü: Settings → Data Sources
3. Wähle Prometheus
4. URL: http://localhost:9090
5. Speichern & Testen
Node Exporter auf Webserver (z. B. 10.0.0.30)
Download und Start
cd /opt wget https://github.com/prometheus/node_exporter/releases/latest/download/node_exporter-1.8.0.linux-amd64.tar.gz tar xvf node_exporter-1.8.0.linux-amd64.tar.gz cd node_exporter-1.8.0.linux-amd64 ./node_exporter &
Testen
curl http://10.0.0.30:9100/metrics
Firewall freischalten (falls aktiv)
sudo ufw allow 9100/tcp
Firewalls (optional)
sudo ufw allow 9090/tcp # Prometheus sudo ufw allow 3000/tcp # Grafana
Übersicht
Komponente | IP-Adresse | Port | Aufgabe |
---|---|---|---|
Prometheus | 10.0.0.20 | 9090 | Metriken sammeln |
Grafana | 10.0.0.20 | 3000 | Visualisierung |
Node Exporter | 10.0.0.30 | 9100 | Metriken vom Webserver |