Alert rules of your own, storage forecasts for Proxmox and Synology, and snooze

- Monitoring -> Alert rules: CPU, memory, disk use and disk temperature limits with a time, severity and scope (all, one server, a tag); try before saving; findings are ordinary health conditions
- Proxmox storages and Synology volumes are written down on each health pass (hourly, 400 days) and forecast like server disks: badge and history chart on the pages, alert, digest line, /metrics gauge
- Snooze an alert until a time; held back like maintenance, messages held, announced once again if still there when it ends
- Docs updated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-20 23:38:36 +02:00
1 parent 788b3e073c
commit 24ae8db380
38 files changed
+7847 -8

No files matched your search

+70
View File
@@ -1224,3 +1224,73 @@ export const eventWebhooks = sqliteTable("event_webhooks", {
lastAttemptAt: text("last_attempt_at"), // ISO
lastResult: text("last_result"), // "200", or what went wrong
});
// ─── Your own alert rules, storage history and snoozes ──────────────────────
export const alertRuleMetrics = ["cpu", "mem", "disk", "disk_temp"] as const;
export type AlertRuleMetric = (typeof alertRuleMetrics)[number];
// "CPU above 90% for 15 minutes", "a disk is warmer than 55 °C": a limit of the administrator's own, judged for every server (or one, or those with a tag) on the
// same pass as the built-in checks, so it alerts, recovers, flaps, is silenced by maintenance and is routed like them — see services/alertRules.ts.
export const alertRules = sqliteTable("alert_rules", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name").notNull(),
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
metric: text("metric").$type<AlertRuleMetric>().notNull(),
mount: text("mount"), // for "disk": one mount point; null = every one
operator: text("operator").$type<"above" | "below">().notNull().default("above"),
threshold: real("threshold").notNull(), // percent, or °C for disk_temp
forMinutes: integer("for_minutes").notNull().default(0), // how long it must have held (0 = right now); not used for disk_temp, which is only known as of the last report
severity: text("severity").$type<"warning" | "critical">().notNull().default("warning"),
serverId: integer("server_id"), // one server; null = see tag. A plain reference: a rule for a server that is gone judges nothing.
tag: text("tag"), // servers with this tag; null with a null server = every server
createdBy: text("created_by"),
createdAt: text("created_at").notNull(), // ISO
});
// What each pool of an integration (a Proxmox storage, a Synology volume) looked like, one reading an hour, so it can be forecast the way an agent server's disk is.
export const storageSeries = sqliteTable(
"storage_series",
{
id: integer("id").primaryKey({ autoIncrement: true }),
integrationId: integer("integration_id")
.notNull()
.references(() => integrations.id, { onDelete: "cascade" }),
key: text("key").notNull(), // "proxmox:<node>:storage:<id>", "proxmox:shared:<id>", "proxmox:<node>:rootfs", "synology:<volume>"
label: text("label").notNull(), // "Storage local-lvm on pve1"
latestPercent: real("latest_percent").notNull(),
usedBytes: integer("used_bytes"),
totalBytes: integer("total_bytes"),
updatedAt: text("updated_at").notNull(), // ISO; the last reading
},
(t) => [uniqueIndex("storage_series_key_idx").on(t.integrationId, t.key)],
);
export const storageSamples = sqliteTable(
"storage_samples",
{
id: integer("id").primaryKey({ autoIncrement: true }),
seriesId: integer("series_id")
.notNull()
.references(() => storageSeries.id, { onDelete: "cascade" }),
at: text("at").notNull(), // ISO
value: real("value").notNull(), // percent used
},
(t) => [index("storage_samples_series_idx").on(t.seriesId, t.at)],
);
// "Remind me tomorrow at 09:00": an alert hidden until a time, and announced again then if it is still there — see services/alertSnoozes.ts. Keyed like an acknowledgement.
export const alertSnoozes = sqliteTable(
"alert_snoozes",
{
id: integer("id").primaryKey({ autoIncrement: true }),
alertId: text("alert_id").notNull(), // the alert's id on the Alerts page
conditionKey: text("condition_key").notNull(), // the key behind it, which the notifications carry
message: text("message").notNull(), // what it said, for the reminder
until: text("until").notNull(), // ISO
snoozedBy: text("snoozed_by").notNull(),
snoozedAt: text("snoozed_at").notNull(), // ISO
lastSeenAt: text("last_seen_at").notNull(), // ISO; the last time the alert was there
},
(t) => [uniqueIndex("alert_snoozes_alert_idx").on(t.alertId)],
);