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

+172 -1
View File
@@ -95,6 +95,24 @@ export interface UserRecord {
role: UserRole;
createdAt: string;
lastLoginAt: string | null;
/** The groups the identity provider reported at their last sign-in; null until they have signed in with groups available. */
groups: string[] | null;
}
/** How roles are decided at sign-in: by hand on the Users page, or from the groups the identity provider reports. */
export interface SignInSettings {
roleFromGroups: boolean;
groupsClaim: string;
adminGroups: string[];
operatorGroups: string[];
otherwise: "viewer" | "keep";
}
/** What each person would be under a draft of the group rules. */
export interface GroupRolePreview {
people: { id: number; name: string; role: UserRole; groups: string[] | null; wouldBe: UserRole | null }[];
/** How many administrators there would be; 0 means the rules would lock everyone out of administration. */
adminsAfter: number;
}
export interface SessionSummary {
@@ -423,6 +441,7 @@ export interface AppSettings {
quietHours: QuietHoursSettings;
healthChecks: HealthCheckSettings;
digest: DigestSettings;
signIn: SignInSettings;
}
export type AppSettingsPatch = { [K in keyof AppSettings]?: Partial<AppSettings[K]> };
@@ -586,6 +605,125 @@ export interface ServerDetail {
agentLatest: AgentLatest;
}
/** A token that opens /metrics for Prometheus, as the list shows it (never the secret). */
export interface MetricsToken {
id: number;
label: string;
tokenPrefix: string;
createdBy: string | null;
createdAt: string;
lastUsedAt: string | null;
}
export type WebhookEventName = "alert.opened" | "alert.resolved" | "maintenance.started" | "maintenance.ended";
/** A URL sent a signed JSON message when something happens. */
export interface EventWebhook {
id: number;
label: string;
url: string;
hasSecret: boolean;
events: WebhookEventName[];
enabled: boolean;
createdBy: string | null;
createdAt: string;
lastAttemptAt: string | null;
/** "200", or what went wrong. */
lastResult: string | null;
}
export type CoverageStatus = "ok" | "stale" | "failed" | "none" | "unknown";
/** One Proxmox guest and how well it is backed up. */
export interface CoverageGuest {
integrationId: number;
integrationName: string;
node: string;
vmid: number;
name: string;
type: "qemu" | "lxc";
power: string;
/** A backup job covers it. */
inJob: boolean;
lastBackupAt: string | null;
lastSource: "pbs" | "task" | null;
status: CoverageStatus;
failure: string | null;
server: { id: number; name: string } | null;
}
export interface BackupCoverage {
guests: CoverageGuest[];
counts: Record<CoverageStatus, number> & { total: number };
sources: { kind: "proxmox" | "pbs"; name: string; ok: boolean; error?: string }[];
staleHours: number;
generatedAt: string;
}
export type AssetKind = "server" | "storage" | "network" | "power" | "client" | "other";
/** A piece of hardware in the inventory. */
export interface Asset {
id: number;
name: string;
kind: AssetKind;
manufacturer: string | null;
model: string | null;
serial: string | null;
purchaseDate: string | null;
purchasePrice: number | null;
warrantyUntil: string | null;
location: string | null;
rackUnit: string | null;
powerWatts: number | null;
serverId: number | null;
notes: string | null;
createdAt: string;
updatedAt: string;
/** The server it is, when it is one and that server still exists. */
server: { id: number; name: string } | null;
}
/** What an entry is saved from: blank text and nulls mean "no value". */
export interface AssetInput {
name: string;
kind: AssetKind;
manufacturer?: string | null;
model?: string | null;
serial?: string | null;
purchaseDate?: string | null;
purchasePrice?: number | null;
warrantyUntil?: string | null;
location?: string | null;
rackUnit?: string | null;
powerWatts?: number | null;
serverId?: number | null;
notes?: string | null;
}
/** What the running cost is worked out with. */
export interface InventoryConfig {
currency: string;
pricePerKwh: number | null;
}
/** A note about what to do when something is wrong with a server, integration or DNS provider. */
export interface Runbook {
id: number;
targetType: MaintenanceTargetType;
targetId: number;
title: string;
body: string;
/** An alert category it is for, or null for anything about the target. */
category: AlertCategory | null;
updatedBy: string | null;
createdAt: string;
updatedAt: string;
}
/** A runbook's title and what it is for, without its text. */
export type RunbookSummary = Pick<Runbook, "id" | "targetType" | "targetId" | "category" | "title">;
export type AlertSeverity = "critical" | "warning" | "info";
export type AlertCategory = "offline" | "disk" | "backup" | "updates" | "expiry" | "automation" | "integration" | "monitoring" | "tickets";
@@ -1279,6 +1417,37 @@ export const api = {
uptime: {
get: () => request<UptimeReport>("/api/uptime"),
},
metricsTokens: {
list: () => request<{ tokens: MetricsToken[] }>("/api/metrics-tokens"),
create: (label: string) => request<{ token: MetricsToken; secret: string }>("/api/metrics-tokens", { method: "POST", body: JSON.stringify({ label }) }),
remove: (id: number) => request<void>(`/api/metrics-tokens/${id}`, { method: "DELETE" }),
},
eventWebhooks: {
list: () => request<{ webhooks: EventWebhook[]; events: WebhookEventName[] }>("/api/event-webhooks"),
create: (data: { label: string; url: string; secret?: string; events: WebhookEventName[] }) => request<{ webhook: EventWebhook }>("/api/event-webhooks", { method: "POST", body: JSON.stringify(data) }),
setEnabled: (id: number, enabled: boolean) => request<{ webhook: EventWebhook }>(`/api/event-webhooks/${id}`, { method: "PATCH", body: JSON.stringify({ enabled }) }),
remove: (id: number) => request<void>(`/api/event-webhooks/${id}`, { method: "DELETE" }),
test: (id: number) => request<{ ok: boolean; result: string }>(`/api/event-webhooks/${id}/test`, { method: "POST" }),
},
backups: {
coverage: (staleDays: number, refresh = false) => request<BackupCoverage>(`/api/backups/coverage?staleDays=${staleDays}${refresh ? "&refresh=1" : ""}`),
},
inventory: {
list: () => request<{ assets: Asset[]; config: InventoryConfig; servers: { id: number; name: string }[] }>("/api/inventory"),
create: (data: AssetInput) => request<{ asset: Asset }>("/api/inventory", { method: "POST", body: JSON.stringify(data) }),
update: (id: number, data: AssetInput) => request<{ asset: Asset }>(`/api/inventory/${id}`, { method: "PUT", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/inventory/${id}`, { method: "DELETE" }),
setConfig: (data: InventoryConfig) => request<{ config: InventoryConfig }>("/api/inventory/config", { method: "PUT", body: JSON.stringify(data) }),
},
runbooks: {
list: (targetType: MaintenanceTargetType, targetId: number) => request<{ runbooks: Runbook[] }>(`/api/runbooks?targetType=${targetType}&targetId=${targetId}`),
summary: () => request<{ runbooks: RunbookSummary[] }>("/api/runbooks/summary"),
create: (data: { targetType: MaintenanceTargetType; targetId: number; title: string; body: string; category: AlertCategory | null }) =>
request<{ runbook: Runbook }>("/api/runbooks", { method: "POST", body: JSON.stringify(data) }),
update: (id: number, data: { title: string; body: string; category: AlertCategory | null }) =>
request<{ runbook: Runbook }>(`/api/runbooks/${id}`, { method: "PUT", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/runbooks/${id}`, { method: "DELETE" }),
},
shareLinks: {
list: () => request<{ links: ShareLink[] }>("/api/share-links"),
create: (data: { label: string; detail: ShareLinkDetail; expiresInDays: number | null }) =>
@@ -1297,7 +1466,9 @@ export const api = {
query: (q: string) => request<SearchResponse>(`/api/search?q=${encodeURIComponent(q)}`),
},
users: {
list: () => request<{ users: UserRecord[] }>("/api/users"),
list: () => request<{ users: UserRecord[]; rolesFollowGroups: boolean }>("/api/users"),
previewGroupRoles: (rules: Pick<SignInSettings, "groupsClaim" | "adminGroups" | "operatorGroups" | "otherwise">) =>
request<GroupRolePreview>("/api/users/preview-group-roles", { method: "POST", body: JSON.stringify(rules) }),
updateRole: (id: number, role: UserRole) =>
request<{ user: UserRecord }>(`/api/users/${id}/role`, {
method: "PATCH",