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

+167
View File
@@ -0,0 +1,167 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type ImmichInfo } from "../api/client";
import EmptyState from "../components/EmptyState";
import TimeAgo from "../components/TimeAgo";
import { BlockSkeleton } from "../components/Skeleton";
import { ErrorNotice } from "../components/Notice";
import { formatBytes } from "./settings/StorageSettings";
import { readableError } from "../utils/errors";
function Badge({ i }: { i: ImmichInfo }) {
if (!i.enabled) return <span className="badge bg-secondary-lt text-secondary">Off</span>;
if (!i.state) return <span className="badge bg-secondary-lt text-secondary">Not read yet</span>;
if (!i.fresh) return <span className="badge bg-yellow-lt text-yellow">Can&rsquo;t be read</span>;
if (i.problems.some((x) => x.severity === "critical")) return <span className="badge bg-red-lt text-red">Needs a look</span>;
if (i.problems.length > 0) return <span className="badge bg-yellow-lt text-yellow">Needs a look</span>;
return <span className="badge bg-green-lt text-green">In order</span>;
}
const n = (v: number | null) => (v === null ? "—" : v.toLocaleString());
function Card({ i }: { i: ImmichInfo }) {
const s = i.state;
const failed = s?.queues?.reduce((total, q) => total + q.failed, 0) ?? 0;
const percent = s?.disk?.percent ?? null;
return (
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">
{i.name} <Badge i={i} />
</h3>
<div className="card-actions text-secondary small">{i.status ? <>read <TimeAgo value={i.status.at} /></> : "not read yet"}</div>
</div>
<div className="card-body">
{i.status && !i.status.ok && <div className="text-yellow mb-2">The last attempt to read it failed: {i.status.error ?? "no answer"}.</div>}
{i.problems.length > 0 && (
<ul className="mb-3">
{i.problems.map((x) => (
<li key={x.key} className={x.severity === "critical" ? "text-red" : ""}>
{x.message}
</li>
))}
</ul>
)}
{s && (
<>
<div className="text-secondary small mb-3">
{[s.version ? `version ${s.version}` : null, s.updateAvailable && s.latestVersion ? `${s.latestVersion} is out` : null].filter(Boolean).join(" · ")}
</div>
<div className="row g-3 mb-3">
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Photos</div>
<div className="h2 mb-0">{n(s.photos)}</div>
</div>
</div>
</div>
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Videos</div>
<div className="h2 mb-0">{n(s.videos)}</div>
</div>
</div>
</div>
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Library</div>
<div className="h2 mb-0">{s.usageBytes === null ? "—" : formatBytes(s.usageBytes)}</div>
</div>
</div>
</div>
<div className="col-6 col-lg-3">
<div className="card card-sm h-100">
<div className="card-body">
<div className="text-secondary small">Disk under it</div>
<div className="h2 mb-0">{percent === null ? "—" : `${Math.round(percent)} %`}</div>
{s.disk && (
<>
<div className="progress progress-sm mt-1" aria-hidden="true">
<div className="progress-bar" style={{ width: `${Math.max(0, Math.min(100, percent ?? 0))}%`, background: (percent ?? 0) >= 95 ? "#d63939" : (percent ?? 0) >= 90 ? "#f59f00" : "#2fb344" }} />
</div>
<div className="text-secondary small">
{formatBytes(s.disk.used)} of {formatBytes(s.disk.size)}
</div>
</>
)}
</div>
</div>
</div>
</div>
<h4>Background jobs{failed > 0 && <span className="text-red fw-normal ms-2">{failed} failed</span>}</h4>
{!s.queues ? (
<div className="text-secondary">Immich did not answer about its jobs (the API key needs to be allowed to read them).</div>
) : (
<div className="table-responsive">
<table className="table table-vcenter table-sm">
<thead>
<tr>
<th>Queue</th>
<th className="text-end">Active</th>
<th className="text-end">Waiting</th>
<th className="text-end">Failed</th>
<th />
</tr>
</thead>
<tbody>
{s.queues.map((q) => (
<tr key={q.name}>
<td>{q.name}</td>
<td className="text-end">{q.active.toLocaleString()}</td>
<td className="text-end">{q.waiting.toLocaleString()}</td>
<td className={`text-end ${q.failed > 0 ? "text-red fw-bold" : "text-secondary"}`}>{q.failed.toLocaleString()}</td>
<td>{q.paused && <span className="badge bg-secondary-lt text-secondary">paused</span>}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</>
)}
</div>
</div>
);
}
/** Immich: whether the photo library is healthy — the disk under it, how many it holds, and whether its background jobs are failing quietly. */
export default function Immich() {
const [data, setData] = useState<ImmichInfo[] | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const load = () =>
api.immich
.list()
.then((r) => {
setData(r.immiches);
setError(null);
})
.catch((err) => setError(readableError(err)));
void load();
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, []);
return (
<>
<h2 className="page-title">Immich</h2>
<p className="text-secondary">
Photos are what cannot be made again, and Immich fails quietly. It is read every few minutes with an API key (see <Link to="/integrations">Integrations</Link>). A <strong>disk under the library that is filling up</strong> and <strong>background jobs that have failed</strong> (thumbnails and
metadata that were never made) are alerts — see <Link to="/alerts">Alerts</Link>.
</p>
<ErrorNotice error={error} />
{!data && !error && <BlockSkeleton lines={4} />}
{data && data.length === 0 && (
<div className="card">
<div className="card-body">
<EmptyState title="No Immich connected" hint="Add one under Integrations with its address and an API key (Account Settings → API Keys; read permissions are enough)." />
</div>
</div>
)}
{data?.map((i) => <Card key={i.id} i={i} />)}
</>
);
}