Prometheus / Grafana: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K Schützte „Prometheus / Grafana“ ([Bearbeiten=Nur Administratoren erlauben] (unbeschränkt) [Verschieben=Nur Administratoren erlauben] (unbeschränkt)) |
Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
= Prometheus + Grafana Installation auf Debian 12 (IP: 10.0.0.20) = | |||
== Voraussetzungen == | |||
* Debian 12 Server mit statischer IP (z. B. <code>10.0.0.20</code>) | |||
* Root- oder Sudo-Zugriff | |||
* Internetverbindung | |||
* Optional: ein zweiter Server/Webserver für Node Exporter (z. B. <code>10.0.0.30</code>) | |||
== System aktualisieren == | |||
<pre> | |||
sudo apt update && sudo apt upgrade -y | |||
</pre> | |||
== Prometheus 2.53.5 installieren == | |||
=== Download und Entpacken === | |||
<pre> | |||
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 | |||
</pre> | |||
=== Benutzer und Verzeichnisse erstellen === | |||
<pre> | |||
sudo useradd --no-create-home --shell /bin/false prometheus | |||
sudo mkdir -p /etc/prometheus /var/lib/prometheus | |||
</pre> | |||
=== Binärdateien kopieren === | |||
<pre> | |||
cd /opt/prometheus | |||
sudo cp prometheus promtool /usr/local/bin/ | |||
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool | |||
</pre> | |||
=== Konfiguration kopieren === | |||
<pre> | |||
sudo cp -r consoles/ console_libraries/ /etc/prometheus/ | |||
sudo cp prometheus.yml /etc/prometheus/ | |||
sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus | |||
</pre> | |||
== Prometheus konfigurieren == | |||
<pre> | |||
sudo nano /etc/prometheus/prometheus.yml | |||
</pre> | |||
Beispiel-Inhalt: | |||
<pre> | |||
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'] | |||
</pre> | |||
== Systemd-Service für Prometheus erstellen == | |||
<pre> | |||
sudo nano /etc/systemd/system/prometheus.service | |||
</pre> | |||
Inhalt: | |||
<pre> | |||
[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 | |||
</pre> | |||
=== Prometheus starten === | |||
<pre> | |||
sudo systemctl daemon-reexec | |||
sudo systemctl enable --now prometheus | |||
</pre> | |||
== Grafana installieren == | |||
=== Repository einrichten === | |||
<pre> | |||
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 | |||
</pre> | |||
=== Grafana installieren === | |||
<pre> | |||
sudo apt install grafana -y | |||
sudo systemctl enable --now grafana-server | |||
</pre> | |||
Webinterface: [http://10.0.0.20:3000](http://10.0.0.20:3000) | |||
Standard-Login: <code>admin</code> / <code>admin</code> | |||
== Grafana mit Prometheus verbinden == | |||
1. Im Browser öffnen: <code>http://10.0.0.20:3000</code> | |||
2. Menü: <code>Settings → Data Sources</code> | |||
3. Wähle <code>Prometheus</code> | |||
4. URL: <code>http://localhost:9090</code> | |||
5. Speichern & Testen | |||
== Node Exporter auf Webserver (z. B. 10.0.0.30) == | |||
=== Download und Start === | |||
<pre> | |||
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 & | |||
</pre> | |||
=== Testen === | |||
<pre> | |||
curl http://10.0.0.30:9100/metrics | |||
</pre> | |||
=== Firewall freischalten (falls aktiv) === | |||
<pre> | |||
sudo ufw allow 9100/tcp | |||
</pre> | |||
== Firewalls (optional) == | |||
<pre> | |||
sudo ufw allow 9090/tcp # Prometheus | |||
sudo ufw allow 3000/tcp # Grafana | |||
</pre> | |||
== Übersicht == | |||
{| class="wikitable" | |||
! 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 | |||
|} |
Version vom 14. Juli 2025, 17:41 Uhr
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 |