====== Runbook: Logs prüfen ====== **Dauer:** ~10 Minuten \\ **Rolle:** Gateway-Operator \\ **Häufigkeit:** Täglich / Bei Problemen Analyse der Gateway-Logs für Fehlerdiagnose und Monitoring. ---- ===== Workflow ===== flowchart TD A[Logs öffnen] --> B[Nach ERROR filtern] B --> C{Fehler gefunden?} C -->|Ja| D[Fehler analysieren] C -->|Nein| E[Nach WARN filtern] D --> F[Maßnahme ergreifen] E --> G{Warnungen?} G -->|Ja| H[Dokumentieren] G -->|Nein| I[OK - Fertig] F --> I H --> I style I fill:#e8f5e9 style D fill:#ffebee style H fill:#fff3e0 ---- ===== 1. Log-Speicherorte ===== | Plattform | Pfad | |-----------|------| | Windows (Konsole) | Konsolenausgabe | | Windows (Service) | ''%GATEWAY_ROOT%\logs\'' oder Event Log | | Linux (systemd) | ''journalctl -u data-gateway'' | | Docker | ''docker logs gateway'' | ---- ===== 2. Letzte Logs anzeigen ===== **Windows (Datei):** # Letzte 50 Zeilen Get-Content -Path "%GATEWAY_ROOT%\logs\gateway.log" -Tail 50 # Live-Tail Get-Content -Path "%GATEWAY_ROOT%\logs\gateway.log" -Wait -Tail 10 **Linux (systemd):** # Letzte 100 Zeilen journalctl -u data-gateway -n 100 --no-pager # Live-Tail journalctl -u data-gateway -f **Docker:** # Letzte 100 Zeilen docker logs --tail 100 gateway # Live-Tail docker logs -f gateway ---- ===== 3. Nach Fehlern filtern ===== **Windows:** # ERROR-Einträge Select-String -Path "%GATEWAY_ROOT%\logs\*.log" -Pattern "ERROR|Exception" # Heute Get-Content "%GATEWAY_ROOT%\logs\gateway.log" | Where-Object { $_ -match "ERROR" -and $_ -match (Get-Date -Format "yyyy-MM-dd") } **Linux:** # ERROR-Einträge journalctl -u data-gateway --since today | grep -E "ERROR|Exception" # Oder in Datei grep -E "ERROR|Exception" /var/log/gateway/gateway.log ---- ===== 4. Häufige Log-Muster ===== **Erfolgreiche Anfrage:** [INFO] GET /api/v1/dsn/demo/tables 200 45ms **Fehler:** [ERROR] GET /api/v1/dsn/invalid/tables 404 Database 'invalid' not found [ERROR] POST /api/v1/dsn/demo/query 500 SqlException: Invalid syntax **Warnung:** [WARN] Slow query detected: 2340ms for GET /api/v1/dsn/produktion/tables/BigTable ---- ===== 5. Log-Level anpassen ===== In ''appsettings.json'': { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "WvdS.WebAPI.Data.Gateway": "Debug" } } } | Level | Verwendung | |-------|------------| | ''Trace'' | Sehr detailliert (Entwicklung) | | ''Debug'' | Debugging-Informationen | | ''Information'' | Normale Operationen (Standard) | | ''Warning'' | Potenzielle Probleme | | ''Error'' | Fehler, die behandelt wurden | | ''Critical'' | Schwere Fehler, Absturz | ---- ===== 6. Checkliste ===== | # | Prüfpunkt | ✓ | |---|-----------|---| | 1 | ERROR-Einträge durchgesehen | ☐ | | 2 | WARN-Einträge durchgesehen | ☐ | | 3 | Slow Queries notiert | ☐ | | 4 | Fehler dokumentiert/gemeldet | ☐ | | 5 | Log-Rotation aktiv | ☐ | ---- ===== Troubleshooting ===== | Log-Meldung | Ursache | Lösung | |-------------|---------|--------| | ''Database not found'' | DSN nicht konfiguriert | appsettings.json prüfen | | ''Connection refused'' | DB nicht erreichbar | Firewall/Netzwerk prüfen | | ''SqlException: Login failed'' | Falsche Credentials | Passwort prüfen | | ''OutOfMemoryException'' | Zu große Abfrage | ''$top'' Limit setzen | | ''Timeout expired'' | DB zu langsam | Index optimieren | ---- ===== Log-Rotation einrichten ===== **Serilog (appsettings.json):** { "Serilog": { "WriteTo": [ { "Name": "File", "Args": { "path": "logs/gateway-.log", "rollingInterval": "Day", "retainedFileCountLimit": 30 } } ] } } ---- ===== Verwandte Runbooks ===== * [[.:health-check|Health Check]] – Verfügbarkeitsprüfung * [[.:server-starten|Server starten]] – Bei Absturz * [[..:monitoring:alerting|Alerting]] – Automatische Benachrichtigung ---- << [[.:health-check|← Health Check]] | [[..:start|→ Operator-Übersicht]] >> ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional// {{tag>operator runbook logs troubleshooting}}