5.9 KiB
5.9 KiB
V2 Docker Monitoring Stack
Übersicht
Die Monitoring-Lösung für V2 Docker basiert auf dem Prometheus-Stack und bietet umfassende Einblicke in die Performance und Gesundheit aller Services.
Komponenten
1. Prometheus (Port 9090)
- Zentrale Metrik-Sammlung
- Konfigurierte Scrape-Jobs für alle Services
- 30 Tage Datenaufbewahrung
- Alert-Rules für kritische Ereignisse
2. Grafana (Port 3000)
- Visualisierung der Metriken
- Vorkonfigurierte Dashboards
- Alerting-Integration
- Standard-Login: admin/admin (beim ersten Login ändern)
3. Alertmanager (Port 9093)
- Alert-Routing und -Gruppierung
- Email-Benachrichtigungen
- Webhook-Integration
- Alert-Silencing und -Inhibition
4. Exporters
- PostgreSQL Exporter: Datenbank-Metriken
- Redis Exporter: Cache-Metriken
- Node Exporter: System-Metriken
- Nginx Exporter: Proxy-Metriken
Installation
1. Monitoring-Stack starten
cd monitoring
docker-compose -f docker-compose.monitoring.yml up -d
2. Services überprüfen
docker-compose -f docker-compose.monitoring.yml ps
3. Grafana-Zugang
- Öffnen Sie https://monitoring.v2-docker.com (oder http://localhost:3000)
- Login mit admin/admin
- Neues Passwort setzen
- Dashboard "License Server Overview" öffnen
Konfiguration
Environment-Variablen
Erstellen Sie eine .env Datei im monitoring-Verzeichnis:
# Grafana
GRAFANA_USER=admin
GRAFANA_PASSWORD=secure-password
# PostgreSQL Connection
POSTGRES_PASSWORD=your-postgres-password
# Alertmanager SMTP
SMTP_USERNAME=alerts@yourdomain.com
SMTP_PASSWORD=smtp-password
# Webhook URLs
WEBHOOK_CRITICAL=https://your-webhook-url/critical
WEBHOOK_SECURITY=https://your-webhook-url/security
Alert-Konfiguration
Alerts sind in prometheus/rules/license-server-alerts.yml definiert:
- HighLicenseValidationErrorRate: Fehlerrate > 5%
- PossibleLicenseAbuse: Verdächtige Aktivitäten
- LicenseServerDown: Service nicht erreichbar
- HighLicenseValidationLatency: Antwortzeit > 500ms
- DatabaseConnectionPoolExhausted: DB-Verbindungen > 90%
Neue Alerts hinzufügen
- Editieren Sie
prometheus/rules/license-server-alerts.yml - Fügen Sie neue Alert-Regel hinzu:
- alert: YourAlertName
expr: your_prometheus_query > threshold
for: 5m
labels:
severity: warning
service: your-service
annotations:
summary: "Alert summary"
description: "Detailed description"
- Prometheus neu laden:
curl -X POST http://localhost:9090/-/reload
Dashboards
License Server Overview
Zeigt wichtige Metriken:
- Aktive Lizenzen
- Validierungen pro Sekunde
- Fehlerrate
- Response Time Percentiles
- Anomalie-Erkennung
- Top 10 aktivste Lizenzen
Neue Dashboards erstellen
- In Grafana einloggen
- Create → Dashboard
- Panel hinzufügen
- Prometheus-Query eingeben
- Dashboard speichern
- Export als JSON für Backup
Metriken
License Server Metriken
license_validation_total: Anzahl der Validierungenlicense_validation_duration_seconds: Validierungs-Daueractive_licenses_total: Aktive Lizenzenanomaly_detections_total: Erkannte Anomalien
System Metriken
node_cpu_seconds_total: CPU-Auslastungnode_memory_MemAvailable_bytes: Verfügbarer Speichernode_filesystem_avail_bytes: Verfügbarer Festplattenspeicher
Datenbank Metriken
pg_stat_database_numbackends: Aktive DB-Verbindungenpg_stat_database_tup_fetched: Abgerufene Tupelpg_stat_database_conflicts: Konflikte
Troubleshooting
Prometheus erreicht Service nicht
- Netzwerk überprüfen:
docker network inspect v2_internal_net
- Service-Discovery testen:
docker exec prometheus wget -O- http://license-server:8443/metrics
Keine Daten in Grafana
-
Datasource überprüfen:
- Settings → Data Sources → Prometheus
- Test Connection
-
Prometheus Targets checken:
- http://localhost:9090/targets
- Alle Targets sollten "UP" sein
Alerts werden nicht gesendet
- Alertmanager Logs prüfen:
docker logs alertmanager
- SMTP-Konfiguration verifizieren
- Webhook-URLs testen
Wartung
Backup
- Prometheus-Daten:
docker exec prometheus tar czf /prometheus/backup.tar.gz /prometheus
docker cp prometheus:/prometheus/backup.tar.gz ./backups/
- Grafana-Dashboards:
- Export über UI als JSON
- Speichern in
grafana/dashboards/
Updates
- Images updaten:
docker-compose -f docker-compose.monitoring.yml pull
docker-compose -f docker-compose.monitoring.yml up -d
- Konfiguration neu laden:
# Prometheus
curl -X POST http://localhost:9090/-/reload
# Alertmanager
curl -X POST http://localhost:9093/-/reload
Performance-Optimierung
Retention anpassen
In docker-compose.monitoring.yml:
command:
- '--storage.tsdb.retention.time=15d' # Reduzieren für weniger Speicher
Scrape-Intervalle
In prometheus/prometheus.yml:
global:
scrape_interval: 30s # Erhöhen für weniger Last
Resource Limits
Passen Sie die Limits in docker-compose.monitoring.yml an Ihre Umgebung an.
Sicherheit
- Grafana: Ändern Sie das Standard-Passwort sofort
- Prometheus: Kein öffentlicher Zugriff (nur intern)
- Alertmanager: Webhook-URLs geheim halten
- Exporters: Nur im internen Netzwerk erreichbar
Integration
In CI/CD Pipeline
# Deployment-Metriken senden
curl -X POST http://prometheus-pushgateway:9091/metrics/job/deployment \
-d 'deployment_status{version="1.2.3",environment="production"} 1'
Custom Metriken
In Ihrer Anwendung:
from prometheus_client import Counter, Histogram
custom_metric = Counter('my_custom_total', 'Description')
custom_metric.inc()
Support
Bei Problemen:
- Logs überprüfen:
docker-compose -f docker-compose.monitoring.yml logs [service] - Dokumentation: https://prometheus.io/docs/
- Grafana Docs: https://grafana.com/docs/