monitoring/backup-monitor/README.md

71 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🛡️ Backup Monitor The Sentinel
Zentrales Backup-Monitoring-Dashboard für Borgmatic-Backups mit MongoDB Backend, Sentinel UI, Prometheus Metrics und Webhook-Alerts.
## Features
- **Sentinel Web-UI** Dashboard, Alert Center, Host Grid, 30-Tage Kalender-Heatmap
- **Prometheus `/metrics`** Scrape-fähig für Grafana Dashboards
- **Uptime Kuma Push-Forwarding** Single Point of Contact (Borgmatic → Monitor → Kuma)
- **Webhook Alerts** Error/Stale Events an n8n, Telegram, etc.
- **Auto-Register** Hosts registrieren sich automatisch beim ersten Push
- **90 Tage Retention** MongoDB TTL-Index, automatisch
## Stack
- Python 3.12 / Flask / Gunicorn
- MongoDB 8
- Tailwind CSS, Material 3 Design Tokens, Glassmorphism
## Deployment
Läuft als Teil des `monitoring` Stacks auf `10.1.1.111:9999`.
```yaml
backup-monitor:
build: ./backup-monitor
ports:
- "9999:9999"
environment:
- MONGO_URI=mongodb://backup-mongo:27017
- STALE_HOURS=26
- API_KEY=<optional>
- WEBHOOK_URLS=<kommasepariert>
- WEBHOOK_EVENTS=error,stale
```
## Borgmatic Integration
Borgmatic pusht nach jedem Backup via `after_backup` Hook:
```bash
curl -X POST -H "Content-Type: application/json" \
-d '{"host":"<hostname>","status":"ok","duration_sec":123,...}' \
http://10.1.1.111:9999/api/push
```
Template: `roles/borg/templates/borgmatic.yml.j2` im Ansible-Repo.
## API
| Method | Endpoint | Auth | Beschreibung |
|--------|----------|------|-------------|
| GET | `/` | ❌ | Web UI |
| GET | `/metrics` | ❌ | Prometheus Metriken |
| GET | `/api/summary` | ❌ | Dashboard-Zusammenfassung |
| GET | `/api/hosts` | ❌ | Alle Hosts mit Status |
| GET | `/api/history/<host>` | ❌ | Backup-History |
| GET | `/api/calendar/<host>` | ❌ | Kalender-Heatmap |
| POST | `/api/push` | 🔑 | Backup-Status pushen |
| POST | `/api/hosts` | 🔑 | Host hinzufügen |
| PUT | `/api/hosts/<name>` | 🔑 | Host bearbeiten |
| DELETE | `/api/hosts/<name>` | 🔑 | Host + History löschen |
🔑 = benötigt `API_KEY` falls gesetzt (Header `X-API-Key` oder `?api_key=`)
## Neuen Host hinzufügen
1. Borgmatic auf dem Host deployen: `./pfannkuchen.sh backup <host>`
2. Oder manuell über Web-UI: `http://10.1.1.111:9999` → Host hinzufügen
3. Uptime Kuma Push-URL eintragen (optional)
4. Host registriert sich automatisch beim ersten Backup-Push