====== Runbook: Health Check ======
**Dauer:** ~2 Minuten \\
**Rolle:** Gateway-Operator \\
**Häufigkeit:** Täglich / Automatisiert
Überprüfung der Gateway-Verfügbarkeit und Funktionalität.
----
===== Workflow =====
flowchart TD
A[Health Check starten] --> B[/health Endpoint]
B --> C{Healthy?}
C -->|Ja| D[API-Test]
C -->|Nein| E[Logs prüfen]
D --> F{Daten zurück?}
F -->|Ja| G[OK - Fertig]
F -->|Nein| H[DSN prüfen]
E --> I[Server neustarten]
H --> I
style G fill:#e8f5e9
style E fill:#ffebee
style H fill:#fff3e0
----
===== 1. Basic Health Check =====
# Einfacher Health Check
curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/health
# Erwartete Antwort: 200
# Mit Response-Body
curl -s http://localhost:5000/health
# Erwartete Antwort: "Healthy"
----
===== 2. Extended Health Check =====
# Swagger erreichbar?
curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/swagger
# API-Version prüfen
curl -s http://localhost:5000/api/v1/info | jq
----
===== 3. DSN-Konnektivität =====
# Alle DSN durchgehen
for dsn in demo produktion reporting; do
echo "Testing $dsn..."
curl -s -o /dev/null -w "$dsn: %{http_code}\n" \
"http://localhost:5000/api/v1/dsn/$dsn/tables"
done
**PowerShell-Version:**
$dsns = @("demo", "produktion", "reporting")
foreach ($dsn in $dsns) {
$result = Invoke-WebRequest -Uri "http://localhost:5000/api/v1/dsn/$dsn/tables" -UseBasicParsing
Write-Host "$dsn : $($result.StatusCode)"
}
----
===== 4. Response-Zeit messen =====
# Einzelne Abfrage
curl -s -o /dev/null -w "Zeit: %{time_total}s\n" \
"http://localhost:5000/api/v1/dsn/demo/tables/Products?\$top=10"
# Mehrere Durchläufe
for i in {1..5}; do
curl -s -o /dev/null -w "%{time_total}\n" \
"http://localhost:5000/api/v1/dsn/demo/tables/Products?\$top=10"
done | awk '{sum+=$1} END {print "Durchschnitt: " sum/NR "s"}'
----
===== 5. Checkliste =====
| # | Prüfpunkt | Erwartung | ✓ |
|---|-----------|-----------|---|
| 1 | /health | 200 + "Healthy" | ☐ |
| 2 | /swagger | 200 | ☐ |
| 3 | DSN "demo" erreichbar | 200 | ☐ |
| 4 | Response-Zeit | < 1s | ☐ |
| 5 | Keine Fehler in Logs | Keine ERROR | ☐ |
----
===== Automatisierter Health Check =====
**Cron (Linux):**
# /etc/cron.d/gateway-health
*/5 * * * * root curl -sf http://localhost:5000/health || systemctl restart data-gateway
**Scheduled Task (Windows):**
# health-check.ps1
$response = Invoke-WebRequest -Uri "http://localhost:5000/health" -UseBasicParsing -TimeoutSec 5
if ($response.StatusCode -ne 200) {
Restart-Service -Name "DataGateway" -Force
Send-MailMessage -To "admin@example.com" -Subject "Gateway Restart" -Body "Gateway wurde automatisch neugestartet"
}
----
===== Troubleshooting =====
| Problem | Ursache | Lösung |
|---------|---------|--------|
| ''Connection refused'' | Gateway nicht gestartet | Server starten |
| ''503 Service Unavailable'' | Startup noch nicht fertig | 30s warten, erneut prüfen |
| ''500 Internal Server Error'' | Config-Fehler | Logs prüfen |
| Timeout | Gateway überlastet | Last reduzieren, Ressourcen erhöhen |
----
===== Schwellwerte =====
| Metrik | Grün | Gelb | Rot |
|--------|------|------|-----|
| Response-Zeit | < 500ms | 500ms-2s | > 2s |
| Error-Rate | < 1% | 1-5% | > 5% |
| CPU | < 50% | 50-80% | > 80% |
| Memory | < 70% | 70-90% | > 90% |
----
===== Verwandte Runbooks =====
* [[.:server-starten|Server starten]] – Bei Ausfall
* [[.:logs-pruefen|Logs prüfen]] – Fehleranalyse
* [[..:monitoring:prometheus|Prometheus]] – Automatisches Monitoring
----
<< [[.:dsn-verwalten|← DSN verwalten]] | [[.:logs-pruefen|→ Logs prüfen]] >>
----
//Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional//
{{tag>operator runbook health check monitoring}}