A year of history, one chart, and a read API with personal tokens

History: server load, memory and disks are also kept as hourly (four months) and
daily (over two years) averages with lowest and highest; endpoint answers as
hourly (four months) beside the daily figures. Charts ask for 24 hours to a year
and are drawn from whichever is fine enough. A disk that two weeks call flat is
looked at again over ninety days for the forecast. Built once from what is kept.

One chart: TimeChart replaces the sparkline and the multi-line chart: hover and
arrow-key readout, a lowest/highest band, gaps shown as gaps, the same ranges
everywhere and the choice remembered. Used for server trends, comparing servers,
a check's availability and answer times (Endpoints > History) and a server's
availability.

Read API: /api/v1 (servers, metrics, alerts, incidents, inventory, network,
endpoints and their history, maintenance) with personal read-only tokens made
under the user menu: shown once, hashed, 30/90/365 days or none, ten at most,
removed with their owner. GET only. Documented in API.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-20 20:22:58 +02:00
1 parent 5e26e77340
commit 68b41b5586
47 files changed
+12360 -247

No files matched your search

+17
View File
@@ -55,6 +55,9 @@ erDiagram
endpoint_checks ||--o{ endpoint_results : "cascade"
heartbeats ||--o{ heartbeat_pings : "cascade"
integration_credentials ||--o{ integrations : "credential (set null)"
users ||--o{ api_tokens : "cascade"
servers ||--o{ server_metrics_rollup : "cascade"
endpoint_checks ||--o{ endpoint_hourly : "cascade"
integrations ||--o{ network_devices : "cascade"
integrations ||--o{ network_segments : "cascade"
integrations ||--o{ network_server_links : "cascade"
@@ -283,6 +286,12 @@ removed whenever a new sample is stored).
| `value` | real NOT NULL | Percent, 0–100, one decimal. |
| `recorded_at` | text NOT NULL | ISO. |
#### `server_metrics_rollup`
The same figures kept coarser and longer, so charts reach back a year: one row per server, figure and hour (`grain` `h`, kept 120 days) or day (`d`, kept 800 days). `at` is the start of the hour or day (ISO); `sum` and `n` give the average (and are added to as
samples arrive), `min` and `max` the lowest and highest. Written with each sample (see `server_metrics`); built once from the samples already kept when it was added (internal flag `metricsRollupBackfilled`). Primary key (`server_id`, `metric`, `grain`, `at`); deleted with its server.
A chart over up to 35 days is drawn from the samples, up to 120 from the hours, longer from the days.
Index **`server_metrics_lookup_idx`** on (`server_id`, `metric`, `recorded_at`).
#### `server_ports`
@@ -590,6 +599,14 @@ One time a plan ran, and how it went for each server.
One row per endpoint check per UTC day: `total` times asked, `ok` of them answered, `ms_sum`/`ms_count` for the average answer time. Kept about two years (`endpoint_results` keeps two weeks); started from the results that existed when it was added. The monthly report's endpoint availability is worked from it. Primary key (`check_id`, `day`); deleted with its check.
#### `endpoint_hourly`
One row per endpoint check per UTC hour (`hour`, ISO): `total`, `ok`, `ms_sum`, `ms_count` and `ms_max` (the slowest good answer). Kept 120 days — between the results (two weeks) and the daily figures (years) — so an answer-time chart can reach back beyond two weeks. Built once from the results already kept when it was added (internal flag `endpointHourlyBackfilled`). Primary key (`check_id`, `hour`); deleted with its check.
#### `api_tokens`
A person's personal read-only API tokens (see API.md): `user_id` (→ `users.id`, **cascade**: they go with the person), `label`, `token_hash` (SHA-256, unique — the secret itself is shown once and not kept), `token_prefix` (its first twelve characters, to tell tokens apart), `created_at`, `last_used_at` (written at most once a minute) and `expires_at` (null = until removed).
#### `renewals`
A certificate, domain registration or secret whose expiry moved at least 20 days later when the app re-read it: `kind` (`certificate`, `domain`, `secret`), `subject` (its name as it was), `at`, `from_date`, `to_date`. Written once per renewal; read by the monthly report.