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:
1 parent
c36e2092c5
commit
c17e9aa140
55 files changed
+7177
-27
No files matched your search
@@ -20,6 +20,9 @@ export const users = sqliteTable("users", {
|
||||
favorites: text("favorites"),
|
||||
// When this person last pressed "Got it" on the dashboard summary of what changed; the next summary starts from here (ISO).
|
||||
lastLookedAt: text("last_looked_at"),
|
||||
// The groups the identity provider said this person was in at their last sign-in, as a JSON array — shown on the Users page so the group
|
||||
// names can be matched to roles (Settings → Sign-in). Null until they have signed in with groups available.
|
||||
groups: text("groups"),
|
||||
// How this person arranged the dashboard: a JSON object with the cards they hid ("hidden": ["Gitea"]) and the order of the others
|
||||
// ("order": {"DNS": 0, "Secrets": 1}). Follows them to any browser; null is the default layout.
|
||||
dashboardLayout: text("dashboard_layout"),
|
||||
@@ -539,3 +542,85 @@ export const maintenanceSchedules = sqliteTable("maintenance_schedules", {
|
||||
.notNull()
|
||||
.default(sql`(current_timestamp)`),
|
||||
});
|
||||
|
||||
// ─── Runbooks: what to do when something is wrong ───────────────────────────
|
||||
|
||||
// Notes attached to a server, integration or DNS provider — "if this is down, check the UPS first" — shown on its page and next to alerts
|
||||
// about it. A runbook can be for one kind of alert only (`category`, an alert category such as "disk"), or for everything about the thing.
|
||||
export const runbooks = sqliteTable(
|
||||
"runbooks",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
targetType: text("target_type").$type<MaintenanceTargetType>().notNull(),
|
||||
targetId: integer("target_id").notNull(), // polymorphic, like maintenance_windows — no FK; one whose target was deleted is simply not shown
|
||||
title: text("title").notNull(),
|
||||
body: text("body").notNull(),
|
||||
category: text("category"), // null = any alert about the target
|
||||
updatedBy: text("updated_by"),
|
||||
createdAt: text("created_at").notNull(), // ISO
|
||||
updatedAt: text("updated_at").notNull(), // ISO
|
||||
},
|
||||
(t) => [index("runbooks_target_idx").on(t.targetType, t.targetId)],
|
||||
);
|
||||
|
||||
// ─── Inventory: the hardware behind it all ──────────────────────────────────
|
||||
|
||||
export const assetKinds = ["server", "storage", "network", "power", "client", "other"] as const;
|
||||
export type AssetKind = (typeof assetKinds)[number];
|
||||
|
||||
// A piece of hardware: what it is, when it was bought, how long it is covered, where it sits and what it draws. Optionally the server it is.
|
||||
export const assets = sqliteTable("assets", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
name: text("name").notNull(),
|
||||
kind: text("kind").$type<AssetKind>().notNull().default("other"),
|
||||
manufacturer: text("manufacturer"),
|
||||
model: text("model"),
|
||||
serial: text("serial"),
|
||||
purchaseDate: text("purchase_date"), // YYYY-MM-DD
|
||||
purchasePrice: real("purchase_price"), // in the currency set under Settings → Inventory
|
||||
warrantyUntil: text("warranty_until"), // YYYY-MM-DD
|
||||
location: text("location"), // room, rack, shelf
|
||||
rackUnit: text("rack_unit"), // e.g. "U12" or "U12-13"
|
||||
powerWatts: integer("power_watts"), // typical draw, for the running cost
|
||||
serverId: integer("server_id"), // the server this is, if it is one — a plain reference (no FK); one whose server is gone shows as unlinked
|
||||
notes: text("notes"),
|
||||
createdAt: text("created_at").notNull(), // ISO
|
||||
updatedAt: text("updated_at").notNull(), // ISO
|
||||
});
|
||||
|
||||
// ─── Metrics tokens: read-only access to /metrics for Prometheus ────────────
|
||||
|
||||
// Only a hash of the secret is kept (like an agent token or a share link), so it can't be read back out of the database or a backup.
|
||||
export const metricsTokens = sqliteTable("metrics_tokens", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
label: text("label").notNull(), // e.g. "Prometheus"
|
||||
tokenHash: text("token_hash").notNull().unique(),
|
||||
tokenPrefix: text("token_prefix").notNull(),
|
||||
createdBy: text("created_by"),
|
||||
createdAt: text("created_at")
|
||||
.notNull()
|
||||
.default(sql`(current_timestamp)`),
|
||||
lastUsedAt: text("last_used_at"), // ISO
|
||||
});
|
||||
|
||||
// ─── Event webhooks: tell another system when something happens ─────────────
|
||||
|
||||
export const webhookEvents = ["alert.opened", "alert.resolved", "maintenance.started", "maintenance.ended"] as const;
|
||||
export type WebhookEvent = (typeof webhookEvents)[number];
|
||||
|
||||
// A URL that gets a signed JSON message for the events it subscribes to — for Home Assistant, n8n, a status board. Separate from the
|
||||
// chat-style webhook under Settings → Notifications, which carries the same text a person would read.
|
||||
export const eventWebhooks = sqliteTable("event_webhooks", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
label: text("label").notNull(),
|
||||
url: text("url").notNull(),
|
||||
secret: text("secret"), // encrypted at rest; signs each message (HMAC-SHA256 in X-HLM-Signature)
|
||||
events: text("events").notNull(), // JSON: WebhookEvent[]
|
||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||
createdBy: text("created_by"),
|
||||
createdAt: text("created_at")
|
||||
.notNull()
|
||||
.default(sql`(current_timestamp)`),
|
||||
lastAttemptAt: text("last_attempt_at"), // ISO
|
||||
lastResult: text("last_result"), // "200", or what went wrong
|
||||
});
|
||||
Reference in new issue
Block a user