Acknowledge and hand over alerts, incident timelines, and built-in database backups
- Alerts can be acknowledged (note, assignee, duration); acknowledged alerts are left out of what needs attention (sidebar, dashboard strip, cards) but stay raised and counted by /metrics - Incidents: each time an alert is raised and goes away is recorded (alert_acks, alert_incidents, incident_notes, migration 0032), with a timeline of acks, maintenance, changes, update runs, related alerts and notes; Incidents page and a digest section - Backups of Homelab Manager's own database: daily checked VACUUM INTO copies, retention, download, check, upload, delete, and restore staged and applied at start-up before the database opens (pre-restore copy kept); alerts and /metrics for stale or failing backups - Docs: README, BACKUP, DATABASE, NOTIFICATIONS, ROLES, API; tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a5b623444
commit
2744a84719
41 files changed
+6573
-26
No files matched your search
+53
-5
@@ -23,8 +23,10 @@ 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` … `0031`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. |
|
||||
| **Tables** | 31 application tables, plus drizzle's own `__drizzle_migrations`. |
|
||||
| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0032`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. |
|
||||
| **Tables** | 34 application tables, plus drizzle's own `__drizzle_migrations`. |
|
||||
|
||||
**Not in the database, but beside it in the data folder:** the backups of the database itself (`backups/homelab-manager-….sqlite`, taken daily and on request; see [BACKUP.md](BACKUP.md)), and, only while a restore is waiting or has just happened, `restore-pending.sqlite` / `restore-pending.json` and `restore-result.json`.
|
||||
|
||||
**Not in the database:**
|
||||
|
||||
@@ -62,9 +64,9 @@ erDiagram
|
||||
integrations ||--o{ alert_tickets : "osTicket used (set null)"
|
||||
```
|
||||
|
||||
Twelve tables stand alone, with no foreign keys: `settings`, `secrets`,
|
||||
Thirteen tables stand alone, with no foreign keys: `settings`, `secrets`,
|
||||
`ipam_entries`, `domains`, `diag_log`, `notification_queue`,
|
||||
`consistency_ignores`, `tag_definitions`, `share_links`, `maintenance_schedules`, `metrics_tokens`, `event_webhooks`. `maintenance_windows` and `maintenance_aliases` also have no
|
||||
`consistency_ignores`, `tag_definitions`, `share_links`, `maintenance_schedules`, `metrics_tokens`, `event_webhooks`, `alert_incidents`. `maintenance_windows` and `maintenance_aliases` also have no
|
||||
foreign key — see [soft references](#soft-references-not-foreign-keys).
|
||||
|
||||
## Tables
|
||||
@@ -101,7 +103,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`, and `agent_updated` when a server's agent reports a higher version than before, 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` (including `agent_auto_update`), `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`, `update_run` (`start`, `finished`, `failed`, `cancelled` — shown on the server's Activity card), `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. |
|
||||
| `category` | text NOT NULL | Free text. In use: `server` (including the health check's own `went_offline`, `back_online`, `disk_full` and `disk_ok`, and `agent_updated` when a server's agent reports a higher version than before, 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` (including `agent_auto_update`), `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`, `alert` (`ack`, `unack` — with the alert's id; on the thing it is about, so they show on a server's Activity card), `incident` (`note`, `note_removed`), `db_backup` (`create`, `upload`, `download`, `delete`, `restore_staged`, `restore_cancelled`, `settings`), `update_run` (`start`, `finished`, `failed`, `cancelled` — shown on the server's Activity card), `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. |
|
||||
@@ -490,6 +492,51 @@ 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. |
|
||||
|
||||
#### `alert_acks`
|
||||
|
||||
"I'm on it" for one alert. **One row per alert id.**
|
||||
|
||||
| Column | Type | Notes |
|
||||
|---|---|---|
|
||||
| `id` | integer PK | |
|
||||
| `alert_key` | text NOT NULL, unique | The alert's stable id (e.g. `offline:offline:server:3`), the same key the Alerts page uses; **not a foreign key**. |
|
||||
| `note` | text NOT NULL | Up to 500 characters; may be empty. |
|
||||
| `assignee_user_id` | integer | → `users.id`, set to null if the user is removed. |
|
||||
| `assignee_name` | text | The name as it was when handed over, so it still reads if the user is removed. |
|
||||
| `acked_by` | text NOT NULL | |
|
||||
| `acked_at` | text NOT NULL | ISO. |
|
||||
| `until` | text | ISO; when it runs out. Null means until the alert is gone. |
|
||||
| `last_seen_at` | text NOT NULL | ISO; the last time the alert was there. A row whose alert has been gone for 30 minutes is deleted. |
|
||||
|
||||
#### `alert_incidents`
|
||||
|
||||
One time an alert was raised and later went away. When the same alert comes back it is a new row. Information-only alerts are not recorded.
|
||||
|
||||
| Column | Type | Notes |
|
||||
|---|---|---|
|
||||
| `id` | integer PK | |
|
||||
| `alert_key` | text NOT NULL | The alert's id (indexed). Not a foreign key. |
|
||||
| `severity`, `peak_severity` | text NOT NULL | As it is now (or was at the end), and the worst it got to. |
|
||||
| `category`, `source`, `message`, `link` | text | As the Alerts page showed them; `message` is the latest wording. |
|
||||
| `target_type`, `target_id`, `target_name` | text, integer, text | The server, integration or DNS provider it was about, when there is one (indexed). A plain reference, **not a foreign key**. |
|
||||
| `caused_by` | text | The host whose outage this was folded under. |
|
||||
| `opened_at` | text NOT NULL | ISO. |
|
||||
| `resolved_at` | text | ISO; null while open. Set to when it first went missing, once it has been missing long enough. |
|
||||
| `last_seen_at` | text NOT NULL | ISO. |
|
||||
| `missing_since` | text | ISO; set while it has been missing from the last look(s), before it is called over. |
|
||||
|
||||
Resolved rows older than 400 days are deleted, with their notes.
|
||||
|
||||
#### `incident_notes`
|
||||
|
||||
| Column | Type | Notes |
|
||||
|---|---|---|
|
||||
| `id` | integer PK | |
|
||||
| `incident_id` | integer NOT NULL | → `alert_incidents.id`, deleted with it. |
|
||||
| `author` | text NOT NULL | The person's name at the time. |
|
||||
| `body` | text NOT NULL | Up to 4000 characters. |
|
||||
| `created_at` | text NOT NULL | ISO. |
|
||||
|
||||
#### `update_runs`
|
||||
|
||||
A playbook run in Semaphore for one server, wrapped in a maintenance window and followed until the server reports again.
|
||||
@@ -623,6 +670,7 @@ that were never changed aren't stored; the app fills in defaults when reading.
|
||||
| `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`). |
|
||||
| `selfBackup` | The daily backup of this database: `enabled` (true), `time` (`HH:MM`, default `03:30`, in the notification time zone) and `keep` (14 — how many daily ones are kept). |
|
||||
| `agents` | `autoUpdate` (false): whether agents that are behind replace themselves. |
|
||||
| `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. |
|
||||
|
||||
Reference in new issue
Block a user