Add runbooks, backup coverage, inventory, roles from groups, Prometheus metrics and event webhooks

- Runbooks: notes per server/integration, shown next to matching alerts
- Backup coverage page across Proxmox and PBS, with a digest section
- Hardware inventory with warranty, power and running cost
- Authentik group to role mapping with preview and safeguards
- /metrics (bearer token) and signed outgoing event webhooks
- Docs: README, DATABASE, NOTIFICATIONS, ROLES and new API.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-17 20:41:00 +02:00
1 parent c36e2092c5
commit c17e9aa140
55 files changed
+7177 -27

No files matched your search

+67 -5
View File
@@ -23,8 +23,8 @@ what the app actually creates.
|---|---|
| **File** | `DATABASE_PATH`, default `../data/homelab-manager.sqlite` (relative to `server/`; `/app/data/...` in Docker). The folder is created if missing. |
| **Foreign keys** | Switched on for every connection (`PRAGMA foreign_keys = ON`), so the `ON DELETE` rules below are enforced. |
| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0026`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. |
| **Tables** | 26 application tables, plus drizzle's own `__drizzle_migrations`. |
| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0027`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. |
| **Tables** | 30 application tables, plus drizzle's own `__drizzle_migrations`. |
**Not in the database:**
@@ -62,9 +62,9 @@ erDiagram
integrations ||--o{ alert_tickets : "osTicket used (set null)"
```
Ten tables stand alone, with no foreign keys: `settings`, `secrets`,
Twelve tables stand alone, with no foreign keys: `settings`, `secrets`,
`ipam_entries`, `domains`, `diag_log`, `notification_queue`,
`consistency_ignores`, `tag_definitions`, `share_links`, `maintenance_schedules`. `maintenance_windows` and `maintenance_aliases` also have no
`consistency_ignores`, `tag_definitions`, `share_links`, `maintenance_schedules`, `metrics_tokens`, `event_webhooks`. `maintenance_windows` and `maintenance_aliases` also have no
foreign key — see [soft references](#soft-references-not-foreign-keys).
## Tables
@@ -88,6 +88,7 @@ Everyone who has signed in through Authentik. The first one becomes admin.
| `last_login_at` | text | ISO. |
| `favorites` | text | JSON array of the page paths this person pinned to the top of their menu (`["/servers","/alerts"]`), up to 24. A path may carry a short query for a saved view of a page (`"/servers?status=offline"`). Follows them to any browser. |
| `dashboard_layout` | text | JSON object `{"hidden":["Gitea"],"order":{"Secrets":0,"DNS":1}}`: the dashboard cards this person hid and the order of the rest (lower first; a card with no entry goes last). Null = the default layout. Follows them to any browser. |
| `groups` | text | JSON array of the groups the identity provider reported at this person's last sign-in (null until they have signed in with groups available) — shown on the Users page, and what "roles from groups" works from. |
| `last_looked_at` | text | ISO time this person last pressed "Got it" on the dashboard's "Since you last looked" card; the next summary starts there (null = never: the last day is shown). |
#### `audit_log`
@@ -100,7 +101,7 @@ Who changed what. Written by the app on every change (see
| `id` | integer PK | |
| `actor_user_id` | integer → `users.id`, **set null** on delete | Null for automatic actions, and for entries whose user was deleted. |
| `actor_label` | text | The user's name/email as it was at the time (or `system`), so an entry still reads correctly after the account is gone. |
| `category` | text NOT NULL | Free text. In use: `server` (including the health check's own `went_offline`, `back_online`, `disk_full` and `disk_ok`, written as `system` and shown on a server's Activity card), `integration` (including the health check's `went_failing` / `recovered` for a kind of service, with `target_type` `integration_type` and the service type as `target_id`, which the dashboard summary and the uptime ribbons read), `dns`, `settings`, `ipam`, `secret`, `domain`, `tag`, `task`, `session`, `network`, `maintenance`, `consistency`, `user`, `privacy`, `diag_log`, `alert_ticket`, `share_link` (a link made or removed — never the secret). |
| `category` | text NOT NULL | Free text. In use: `server` (including the health check's own `went_offline`, `back_online`, `disk_full` and `disk_ok`, written as `system` and shown on a server's Activity card), `integration` (including the health check's `went_failing` / `recovered` for a kind of service, with `target_type` `integration_type` and the service type as `target_id`, which the dashboard summary and the uptime ribbons read), `dns`, `settings`, `ipam`, `secret`, `domain`, `tag`, `task`, `session`, `network`, `maintenance`, `consistency`, `user`, `privacy`, `diag_log`, `alert_ticket`, `share_link` (a link made or removed — never the secret), `runbook`, `inventory`, `metrics_token` and `webhook` (made, changed or removed — never a secret or an address). `user` also records `role_from_groups` when a sign-in changed someone's role. |
| `action` | text NOT NULL | `create`, `update`, `delete`, `start`, `stop`, … — free text. |
| `target_type`, `target_id` | text | What it happened to. `target_id` is text so it can hold any kind of ID; there's no foreign key. |
| `detail` | text | JSON, free-form context (what changed, names, counts). Secrets are never put here. |
@@ -486,6 +487,65 @@ checks see it. A row is one *occurrence*: when an alert clears and later returns
| `ticketed_at` | text | ISO; when the ticket was opened. |
| `cleared_at` | text | ISO; null while the alert is still active. Rows cleared more than 180 days ago are deleted. |
#### `runbooks`
Notes about what to do when something is wrong, attached to a server, integration or DNS provider.
| Column | Type | Notes |
|---|---|---|
| `id` | integer PK | |
| `target_type`, `target_id` | text, integer NOT NULL | `server` \| `integration` \| `dns_provider` and its ID. **Not a foreign key**; a note whose target was deleted is simply not shown. Indexed together. |
| `title`, `body` | text NOT NULL | The body is plain text (see README for the little formatting it understands); never rendered as HTML. |
| `category` | text | An alert category (`offline`, `disk`, …) the note is for; null = anything about the target. |
| `updated_by` | text | The person's name at the time. |
| `created_at`, `updated_at` | text NOT NULL | ISO. |
#### `assets`
The hardware inventory.
| Column | Type | Notes |
|---|---|---|
| `id` | integer PK | |
| `name` | text NOT NULL | |
| `kind` | text NOT NULL, default `other` | `server`, `storage`, `network`, `power`, `client` or `other`. |
| `manufacturer`, `model`, `serial`, `location`, `rack_unit`, `notes` | text | |
| `purchase_date`, `warranty_until` | text | `YYYY-MM-DD`. |
| `purchase_price` | real | In the currency set under the `inventory` settings key. |
| `power_watts` | integer | Typical draw, for the running cost. |
| `server_id` | integer | The server this is, if it is one. A plain reference, **not a foreign key**: one whose server is gone shows as unlinked. |
| `created_at`, `updated_at` | text NOT NULL | ISO. |
#### `metrics_tokens`
Read-only access to `/metrics` for Prometheus. Only a hash of each secret is stored.
| Column | Type | Notes |
|---|---|---|
| `id` | integer PK | |
| `label` | text NOT NULL | |
| `token_hash` | text NOT NULL, unique | SHA-256 of the secret, which is shown once and never stored. |
| `token_prefix` | text NOT NULL | The first characters, to tell tokens apart in the list. |
| `created_by` | text | |
| `created_at` | text NOT NULL | |
| `last_used_at` | text | ISO; updated at most once a minute. |
#### `event_webhooks`
URLs sent a signed JSON message when an alert begins or ends or maintenance starts or finishes.
| Column | Type | Notes |
|---|---|---|
| `id` | integer PK | |
| `label` | text NOT NULL | |
| `url` | text NOT NULL | http or https, with no user name or password in it. |
| `secret` | text | Signs each message (HMAC-SHA256). Stored encrypted (`enc:v1:`) when an encryption key is set; never returned by the API. |
| `events` | text NOT NULL | JSON array of `alert.opened`, `alert.resolved`, `maintenance.started`, `maintenance.ended`. |
| `enabled` | bool NOT NULL, default 1 | |
| `created_by` | text | |
| `created_at` | text NOT NULL | |
| `last_attempt_at`, `last_result` | text | When it was last sent to and what came back (`200`, or what went wrong). |
#### `share_links`
Addresses that open a read-only wall display without signing in (Settings → Share
@@ -539,6 +599,8 @@ that were never changed aren't stored; the app fills in defaults when reading.
| `gotify`, `ntfy`, `smtp`, `webhook` | The four notification channels: enabled, address, and credentials (token / password / secret). The credential fields are stored encrypted (prefix `enc:v1:`) — see [Retention and backups](#retention-and-backups). |
| `notifications` | Which events notify (`dnsAdd`, `healthAlerts`, …), the daily-reminder time (`secretCheckTime`, default `08:00`) and `timezone` (default `UTC`), and the integration-failure threshold (default 3). |
| `quietHours` | `enabled`, `start`, `end`. |
| `signIn` | Roles from groups: `roleFromGroups` (false), `groupsClaim` (`groups`), `adminGroups`, `operatorGroups`, `otherwise` (`viewer` or `keep`). |
| `inventory` | `currency` (a short name, may be blank) and `pricePerKwh` (null) — what the inventory's running cost is worked out with. |
| `digest` | The weekly digest: `enabled` (false), `day` (0 = Sunday … 6; default 1, Monday) and `time` (`HH:MM`, default `08:00`), in the notification time zone. |
| `healthChecks` | `serverOfflineMinutes` (60), `diskUsagePercent` (90), `domainWarnDays` (30), `diskForecastDays` (14; 0 = off — how far ahead a filling disk is flagged on the Alerts page). |
| `logRetention` | `enabled`, `retentionDays` (90), `intervalHours` (24). |