Prometheus, Immich and Paperless-ngx integrations

Three read-only integrations, each with a monitoring page, alerts, maintenance
silencing and held-when-unreadable handling.

Prometheus: scrape targets that stop answering (5 minutes, one alert per job)
and alerts that Prometheus's own rules fire (critical when labelled so).
Immich: disk under the library filling, failed background jobs, counts.
Paperless-ngx: worker/database/Redis in error, documents that failed to
import, index and sanity check, disk. Immich and Paperless also in /metrics.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-24 22:33:17 +02:00
1 parent aebe98bf15
commit 251a4a9d73
47 files changed
+24148 -7

No files matched your search

+59
View File
@@ -555,6 +555,9 @@ export const integrationTypes = [
"ups",
"jellyfin",
"authentik",
"prometheus",
"immich",
"paperless",
] as const;
export type IntegrationType = (typeof integrationTypes)[number];
@@ -1161,6 +1164,62 @@ export const haReadings = sqliteTable(
(t) => [index("ha_readings_lookup_idx").on(t.integrationId, t.entityId, t.at)],
);
// ─── Paperless-ngx ──────────────────────────────────────────────────────────
// How a Paperless-ngx (an integration of type "paperless") is right now, one row each, replaced at every read: its version, the disk, how each component of its system status is, the
// document counts and the imports that failed. A column that is null could not be read. Read by services/paperlessSync.ts.
export const paperlessState = sqliteTable("paperless_state", {
integrationId: integer("integration_id")
.primaryKey()
.references(() => integrations.id, { onDelete: "cascade" }),
version: text("version"),
latestVersion: text("latest_version"),
updateAvailable: integer("update_available", { mode: "boolean" }).notNull().default(false),
storageTotal: integer("storage_total"), // bytes
storageAvailable: integer("storage_available"), // bytes
components: text("components"), // JSON: name, status, error — null: the status could not be asked (it needs a superuser)
documents: integer("documents"),
inbox: integer("inbox"),
failed: text("failed"), // JSON: file, error, at — imports that failed in the last week and were not dismissed; null: could not be asked
updatedAt: text("updated_at").notNull(), // ISO
});
// ─── Immich ─────────────────────────────────────────────────────────────────
// How an Immich (an integration of type "immich") is right now, one row each, replaced at every read: its version, the disk under the library, the counts and the background job queues.
// A column that is null could not be read. Read by services/immichSync.ts.
export const immichState = sqliteTable("immich_state", {
integrationId: integer("integration_id")
.primaryKey()
.references(() => integrations.id, { onDelete: "cascade" }),
version: text("version"),
latestVersion: text("latest_version"),
updateAvailable: integer("update_available", { mode: "boolean" }).notNull().default(false),
diskSize: integer("disk_size"), // bytes
diskUsed: integer("disk_used"), // bytes
diskPercent: real("disk_percent"),
photos: integer("photos"),
videos: integer("videos"),
usageBytes: integer("usage_bytes"),
queues: text("queues"), // JSON: name, active, waiting, failed, paused — null: could not be asked
updatedAt: text("updated_at").notNull(), // ISO
});
// ─── Prometheus ─────────────────────────────────────────────────────────────
// How a Prometheus (an integration of type "prometheus") is right now, one row each, replaced at every read: its version, how many targets each job has up and down, which are down
// (and since when), and the alerts its rules have firing. A column that is null could not be read. Read by services/prometheusSync.ts.
export const prometheusState = sqliteTable("prometheus_state", {
integrationId: integer("integration_id")
.primaryKey()
.references(() => integrations.id, { onDelete: "cascade" }),
version: text("version"),
jobs: text("jobs"), // JSON: job, up, down — null: the targets could not be asked
down: text("down"), // JSON: job, instance, error, since
alerts: text("alerts"), // JSON: name, severity, state, summary, instance, activeAt — null: could not be asked
updatedAt: text("updated_at").notNull(), // ISO
});
// ─── Authentik ──────────────────────────────────────────────────────────────
// How an Authentik (an integration of type "authentik") is right now, one row each, replaced at every read: its version, whether a worker is connected, how each outpost is, the