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:
1 parent
aebe98bf15
commit
251a4a9d73
47 files changed
+24148
-7
No files matched your search
@@ -0,0 +1,168 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type PaperlessInfo } 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";
|
||||
|
||||
const NAMES: Record<string, string> = { database: "Database", redis: "Redis", celery: "Document worker", index: "Search index", classifier: "Classifier", sanity_check: "Sanity check" };
|
||||
|
||||
function Badge({ p }: { p: PaperlessInfo }) {
|
||||
if (!p.enabled) return <span className="badge bg-secondary-lt text-secondary">Off</span>;
|
||||
if (!p.state) return <span className="badge bg-secondary-lt text-secondary">Not read yet</span>;
|
||||
if (!p.fresh) return <span className="badge bg-yellow-lt text-yellow">Can’t be read</span>;
|
||||
if (p.problems.some((x) => x.severity === "critical")) return <span className="badge bg-red-lt text-red">Needs a look</span>;
|
||||
if (p.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({ p }: { p: PaperlessInfo }) {
|
||||
const s = p.state;
|
||||
const percent = s?.storage ? Math.round(((s.storage.total - s.storage.available) / s.storage.total) * 100) : null;
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">
|
||||
{p.name} <Badge p={p} />
|
||||
</h3>
|
||||
<div className="card-actions text-secondary small">{p.status ? <>read <TimeAgo value={p.status.at} /></> : "not read yet"}</div>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
{p.status && !p.status.ok && <div className="text-yellow mb-2">The last attempt to read it failed: {p.status.error ?? "no answer"}.</div>}
|
||||
{p.problems.length > 0 && (
|
||||
<ul className="mb-3">
|
||||
{p.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">Documents</div>
|
||||
<div className="h2 mb-0">{n(s.documents)}</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">In the inbox</div>
|
||||
<div className="h2 mb-0">{n(s.inbox)}</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">Failed to import</div>
|
||||
<div className={`h2 mb-0 ${s.failed && s.failed.length > 0 ? "text-red" : ""}`}>{s.failed === null ? "—" : s.failed.length}</div>
|
||||
<div className="text-secondary small">in the last week</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</div>
|
||||
<div className="h2 mb-0">{percent === null ? "—" : `${percent} %`}</div>
|
||||
{s.storage && (
|
||||
<div className="text-secondary small">
|
||||
{formatBytes(s.storage.total - s.storage.available)} of {formatBytes(s.storage.total)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4>System status</h4>
|
||||
{!s.components ? (
|
||||
<div className="text-secondary mb-3">Paperless did not give its system status — that needs the token of a superuser.</div>
|
||||
) : (
|
||||
<ul className="list-unstyled mb-3">
|
||||
{s.components.map((c) => (
|
||||
<li key={c.name}>
|
||||
<span className={`badge me-2 ${c.status === "OK" ? "bg-green-lt text-green" : c.status === "ERROR" ? "bg-red-lt text-red" : "bg-yellow-lt text-yellow"}`}>{c.status === "OK" ? "OK" : c.status === "ERROR" ? "Error" : "Warning"}</span>
|
||||
{NAMES[c.name] ?? c.name}
|
||||
{c.error && <div className="text-secondary small ms-1">{c.error}</div>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{s.failed && s.failed.length > 0 && (
|
||||
<>
|
||||
<h4>Documents that failed to import</h4>
|
||||
<ul className="mb-0">
|
||||
{s.failed.slice(0, 10).map((f, i) => (
|
||||
<li key={`${f.file}-${i}`}>
|
||||
<strong>{f.file}</strong>
|
||||
{f.at && (
|
||||
<span className="text-secondary">
|
||||
{" "}
|
||||
— <TimeAgo value={f.at} />
|
||||
</span>
|
||||
)}
|
||||
{f.error && <div className="text-secondary small">{f.error}</div>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{s.failed.length > 10 && <div className="text-secondary small mt-1">and {s.failed.length - 10} more</div>}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Paperless-ngx: whether the documents are being taken in — the worker, the imports that failed, the inbox, the disk. */
|
||||
export default function Paperless() {
|
||||
const [data, setData] = useState<PaperlessInfo[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
const load = () =>
|
||||
api.paperless
|
||||
.list()
|
||||
.then((r) => {
|
||||
setData(r.paperlesses);
|
||||
setError(null);
|
||||
})
|
||||
.catch((err) => setError(readableError(err)));
|
||||
void load();
|
||||
const t = setInterval(load, 60_000);
|
||||
return () => clearInterval(t);
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title">Paperless-ngx</h2>
|
||||
<p className="text-secondary">
|
||||
Whether documents are being taken in. It is read every few minutes with an API token (see <Link to="/integrations">Integrations</Link>). <strong>A component in error</strong> (above all the worker that consumes documents), <strong>documents that failed to import</strong> and a{" "}
|
||||
<strong>disk that is filling up</strong> 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 Paperless-ngx connected" hint="Add one under Integrations with its address and an API token (a superuser's, to see the system status)." />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{data?.map((p) => <Card key={p.id} p={p} />)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user