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
@@ -13,6 +13,9 @@ import HomeAssistant from "./pages/HomeAssistant";
|
||||
import Ups from "./pages/Ups";
|
||||
import Jellyfin from "./pages/Jellyfin";
|
||||
import Authentik from "./pages/Authentik";
|
||||
import Prometheus from "./pages/Prometheus";
|
||||
import Immich from "./pages/Immich";
|
||||
import Paperless from "./pages/Paperless";
|
||||
import ServiceLevels from "./pages/ServiceLevels";
|
||||
import Duplicati from "./pages/Duplicati";
|
||||
import MyWorkPage from "./pages/MyWork";
|
||||
@@ -162,6 +165,9 @@ function Shelled({ user }: { user: CurrentUser }) {
|
||||
<Route path="/ups" element={<Ups user={user} />} />
|
||||
<Route path="/jellyfin" element={<Jellyfin />} />
|
||||
<Route path="/authentik" element={<Authentik />} />
|
||||
<Route path="/prometheus" element={<Prometheus />} />
|
||||
<Route path="/immich" element={<Immich />} />
|
||||
<Route path="/paperless" element={<Paperless />} />
|
||||
<Route path="/service-levels" element={<ServiceLevels user={user} />} />
|
||||
<Route path="/duplicati" element={<Duplicati user={user} />} />
|
||||
<Route path="/ports" element={<Ports user={user} />} />
|
||||
|
||||
+73
-1
@@ -1228,6 +1228,69 @@ export interface JellyfinInfo {
|
||||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||||
}
|
||||
|
||||
/** One Paperless-ngx, as its page shows it. */
|
||||
export interface PaperlessInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
status: { at: string; ok: boolean; error: string | null } | null;
|
||||
fresh: boolean;
|
||||
state: {
|
||||
version: string | null;
|
||||
latestVersion: string | null;
|
||||
updateAvailable: boolean;
|
||||
storage: { total: number; available: number } | null;
|
||||
/** Null when the status could not be asked (it needs a superuser's token). */
|
||||
components: { name: string; status: string; error: string | null }[] | null;
|
||||
documents: number | null;
|
||||
inbox: number | null;
|
||||
/** Null when the tasks could not be asked. */
|
||||
failed: { file: string; error: string | null; at: string | null }[] | null;
|
||||
updatedAt: string;
|
||||
} | null;
|
||||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||||
}
|
||||
|
||||
/** One Immich, as its page shows it. */
|
||||
export interface ImmichInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
status: { at: string; ok: boolean; error: string | null } | null;
|
||||
fresh: boolean;
|
||||
state: {
|
||||
version: string | null;
|
||||
latestVersion: string | null;
|
||||
updateAvailable: boolean;
|
||||
disk: { size: number; used: number; percent: number | null } | null;
|
||||
photos: number | null;
|
||||
videos: number | null;
|
||||
usageBytes: number | null;
|
||||
/** Null when the queues could not be asked. */
|
||||
queues: { name: string; active: number; waiting: number; failed: number; paused: boolean }[] | null;
|
||||
updatedAt: string;
|
||||
} | null;
|
||||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||||
}
|
||||
|
||||
/** One Prometheus, as its page shows it. */
|
||||
export interface PrometheusInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
status: { at: string; ok: boolean; error: string | null } | null;
|
||||
fresh: boolean;
|
||||
state: {
|
||||
version: string | null;
|
||||
/** Null when the targets could not be asked. */
|
||||
jobs: { job: string; up: number; down: number }[] | null;
|
||||
down: { job: string; instance: string; error: string | null; since: string }[] | null;
|
||||
alerts: { name: string; severity: string | null; state: "firing" | "pending"; summary: string | null; instance: string | null; activeAt: string | null }[] | null;
|
||||
updatedAt: string;
|
||||
} | null;
|
||||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||||
}
|
||||
|
||||
/** One Authentik, as its page shows it. */
|
||||
export interface AuthentikInfo {
|
||||
id: number;
|
||||
@@ -2171,7 +2234,7 @@ export interface ManualTaskInput {
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik";
|
||||
export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless";
|
||||
|
||||
export interface IntegrationField {
|
||||
key: string;
|
||||
@@ -2718,6 +2781,15 @@ export const api = {
|
||||
update: (id: number, data: ServiceLevelInput) => request<{ ok: boolean }>(`/api/service-levels/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||||
remove: (id: number) => request<void>(`/api/service-levels/${id}`, { method: "DELETE" }),
|
||||
},
|
||||
paperless: {
|
||||
list: () => request<{ paperlesses: PaperlessInfo[] }>("/api/paperless"),
|
||||
},
|
||||
immich: {
|
||||
list: () => request<{ immiches: ImmichInfo[] }>("/api/immich"),
|
||||
},
|
||||
prometheus: {
|
||||
list: () => request<{ prometheuses: PrometheusInfo[] }>("/api/prometheus"),
|
||||
},
|
||||
authentik: {
|
||||
list: () => request<{ authentiks: AuthentikInfo[] }>("/api/authentik"),
|
||||
},
|
||||
|
||||
@@ -49,6 +49,9 @@ const INTEGRATION_TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
ups: "UPS",
|
||||
jellyfin: "Jellyfin",
|
||||
authentik: "Authentik",
|
||||
prometheus: "Prometheus",
|
||||
immich: "Immich",
|
||||
paperless: "Paperless-ngx",
|
||||
};
|
||||
|
||||
const DNS_PROVIDER_LABELS: Record<DnsProviderType, string> = {
|
||||
|
||||
@@ -20,6 +20,9 @@ const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
ups: "UPS",
|
||||
jellyfin: "Jellyfin",
|
||||
authentik: "Authentik",
|
||||
prometheus: "Prometheus",
|
||||
immich: "Immich",
|
||||
paperless: "Paperless-ngx",
|
||||
};
|
||||
|
||||
export default function IntegrationEditForm({
|
||||
|
||||
@@ -19,6 +19,9 @@ const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
ups: "UPS",
|
||||
jellyfin: "Jellyfin",
|
||||
authentik: "Authentik",
|
||||
prometheus: "Prometheus",
|
||||
immich: "Immich",
|
||||
paperless: "Paperless-ngx",
|
||||
};
|
||||
|
||||
export default function IntegrationForm({ onCreated, onCancel }: { onCreated: () => void; onCancel: () => void }) {
|
||||
|
||||
@@ -21,6 +21,9 @@ const TYPE_LABELS: Record<string, string> = {
|
||||
ups: "UPS",
|
||||
jellyfin: "Jellyfin",
|
||||
authentik: "Authentik",
|
||||
prometheus: "Prometheus",
|
||||
immich: "Immich",
|
||||
paperless: "Paperless-ngx",
|
||||
};
|
||||
|
||||
export type WallLevel = "critical" | "warning" | "ok" | "unsure";
|
||||
|
||||
@@ -17,8 +17,11 @@ import {
|
||||
IconPlugConnected,
|
||||
IconBrandDocker,
|
||||
IconAffiliate,
|
||||
IconFileText,
|
||||
IconFlame,
|
||||
IconLock,
|
||||
IconMovie,
|
||||
IconPhoto,
|
||||
IconPlayerPlay,
|
||||
IconBrandGit,
|
||||
IconServerCog,
|
||||
@@ -125,6 +128,9 @@ export const NAV: NavEntry[] = [
|
||||
{ to: "/ups", label: "UPS", icon: <IconBatteryCharging size={20} /> },
|
||||
{ to: "/jellyfin", label: "Jellyfin", icon: <IconMovie size={20} /> },
|
||||
{ to: "/authentik", label: "Authentik", icon: <IconLock size={20} /> },
|
||||
{ to: "/prometheus", label: "Prometheus", icon: <IconFlame size={20} /> },
|
||||
{ to: "/immich", label: "Immich", icon: <IconPhoto size={20} /> },
|
||||
{ to: "/paperless", label: "Paperless", icon: <IconFileText size={20} /> },
|
||||
{ to: "/service-levels", label: "Service levels", icon: <IconTargetArrow size={20} /> },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -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’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} />)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,9 @@ const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
ups: "UPS",
|
||||
jellyfin: "Jellyfin",
|
||||
authentik: "Authentik",
|
||||
prometheus: "Prometheus",
|
||||
immich: "Immich",
|
||||
paperless: "Paperless-ngx",
|
||||
};
|
||||
|
||||
/** The page each kind of integration gets once it is connected. */
|
||||
@@ -51,6 +54,9 @@ const TYPE_PAGES: Record<IntegrationType, string> = {
|
||||
ups: "/ups",
|
||||
jellyfin: "/jellyfin",
|
||||
authentik: "/authentik",
|
||||
prometheus: "/prometheus",
|
||||
immich: "/immich",
|
||||
paperless: "/paperless",
|
||||
};
|
||||
|
||||
/** "pve.example.lan" out of "https://pve.example.lan:8006/", or the text itself when it isn't an address. */
|
||||
|
||||
@@ -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} />)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type PrometheusInfo } from "../api/client";
|
||||
import EmptyState from "../components/EmptyState";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { readableError } from "../utils/errors";
|
||||
|
||||
/** Alerts every pipeline carries to prove it works: they are always firing, so they are not shown as firing. */
|
||||
const BY_DESIGN = /^(watchdog|deadmansswitch|deadmanssnitch|infoinhibitor)$/i;
|
||||
|
||||
function Badge({ p }: { p: PrometheusInfo }) {
|
||||
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>;
|
||||
}
|
||||
|
||||
function Card({ p }: { p: PrometheusInfo }) {
|
||||
const s = p.state;
|
||||
const targets = s?.jobs ? s.jobs.reduce((n, j) => n + j.up + j.down, 0) : null;
|
||||
const down = s?.jobs ? s.jobs.reduce((n, j) => n + j.down, 0) : null;
|
||||
const firing = s?.alerts?.filter((a) => a.state === "firing" && !BY_DESIGN.test(a.name)) ?? [];
|
||||
const pending = s?.alerts?.filter((a) => a.state === "pending") ?? [];
|
||||
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, targets === null ? "targets could not be read" : `${targets} target${targets === 1 ? "" : "s"}, ${down} down`, s.alerts === null ? "alerts could not be read" : `${firing.length} alert${firing.length === 1 ? "" : "s"} firing`].filter(Boolean).join(" · ")}
|
||||
</div>
|
||||
|
||||
<h4>Targets by job</h4>
|
||||
{!s.jobs ? (
|
||||
<div className="text-secondary mb-3">Prometheus did not answer about its targets.</div>
|
||||
) : s.jobs.length === 0 ? (
|
||||
<div className="text-secondary mb-3">None.</div>
|
||||
) : (
|
||||
<div className="table-responsive mb-3">
|
||||
<table className="table table-vcenter table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Job</th>
|
||||
<th className="text-end">Up</th>
|
||||
<th className="text-end">Down</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{s.jobs.map((j) => (
|
||||
<tr key={j.job}>
|
||||
<td>{j.job}</td>
|
||||
<td className="text-end">{j.up}</td>
|
||||
<td className={`text-end ${j.down > 0 ? "text-red fw-bold" : "text-secondary"}`}>{j.down}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{s.down && s.down.length > 0 && (
|
||||
<>
|
||||
<h4>Not answering</h4>
|
||||
<ul className="mb-3">
|
||||
{s.down.map((d) => (
|
||||
<li key={`${d.job}-${d.instance}`}>
|
||||
<strong>{d.instance}</strong> <span className="text-secondary">({d.job}) since <TimeAgo value={d.since} /></span>
|
||||
{d.error && <div className="text-secondary small">{d.error}</div>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
|
||||
<h4>Alerts firing</h4>
|
||||
{!s.alerts ? (
|
||||
<div className="text-secondary mb-3">Prometheus did not answer about its alerts.</div>
|
||||
) : firing.length === 0 ? (
|
||||
<div className="text-secondary mb-3">None{pending.length > 0 ? ` (${pending.length} pending)` : ""}.</div>
|
||||
) : (
|
||||
<ul className="mb-3">
|
||||
{firing.map((a, i) => (
|
||||
<li key={`${a.name}-${a.instance}-${i}`} className={a.severity === "critical" ? "text-red" : ""}>
|
||||
<strong>{a.name}</strong>
|
||||
{a.severity && <span className="text-secondary"> ({a.severity})</span>}
|
||||
{a.instance && <span className="text-secondary"> on {a.instance}</span>}
|
||||
{a.summary && <div className="text-secondary small">{a.summary}</div>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Prometheus: whether the targets it scrapes are answering and which of its alerts are firing — what you already measure, in the same list as everything else. */
|
||||
export default function Prometheus() {
|
||||
const [data, setData] = useState<PrometheusInfo[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
const load = () =>
|
||||
api.prometheus
|
||||
.list()
|
||||
.then((r) => {
|
||||
setData(r.prometheuses);
|
||||
setError(null);
|
||||
})
|
||||
.catch((err) => setError(readableError(err)));
|
||||
void load();
|
||||
const t = setInterval(load, 30_000);
|
||||
return () => clearInterval(t);
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title">Prometheus</h2>
|
||||
<p className="text-secondary">
|
||||
What Prometheus already measures, in the same list as everything else. It is read every couple of minutes (see <Link to="/integrations">Integrations</Link>). A <strong>target that has not answered for five minutes</strong> and an <strong>alert that Prometheus’s rules are firing</strong> are
|
||||
alerts — see <Link to="/alerts">Alerts</Link>. Alerts that Grafana manages itself are not seen.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
{!data && !error && <BlockSkeleton lines={4} />}
|
||||
{data && data.length === 0 && (
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
<EmptyState title="No Prometheus connected" hint="Add one under Integrations with its address (http://host:9090)." />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{data?.map((p) => <Card key={p.id} p={p} />)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -29,6 +29,9 @@ const INTEGRATION_NAMES: Record<string, string> = {
|
||||
ups: "UPS",
|
||||
jellyfin: "Jellyfin",
|
||||
authentik: "Authentik",
|
||||
prometheus: "Prometheus",
|
||||
immich: "Immich",
|
||||
paperless: "Paperless-ngx",
|
||||
};
|
||||
|
||||
function ColorList({
|
||||
|
||||
Reference in new issue
Block a user