Add status pages (a share link kind) and a downloadable Grafana dashboard

- Share links can open a status page: an admin picks servers, integrations and Uptime Kuma
  monitors and names them; the public sees only those names, Working / Not working /
  Being worked on / Can't tell, an optional message and the 30-day figure (share_links.kind/
  title/message and status_items, migration 0033). A status address doesn't open the wall and
  the other way round; Uptime Kuma is asked at most every 30 seconds
- Grafana dashboard built from code (download in Settings -> API and webhooks); a test checks
  it only uses series /metrics serves
- Tests and docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 15:38:08 +02:00
1 parent 2744a84719
commit 5cc51c57de
24 files changed
+4880 -35

No files matched your search

+9
View File
@@ -6,6 +6,7 @@ import { metricsTokens } from "../db/schema.js";
import { requireAuth, requireRole } from "../auth/middleware.js";
import { recordAudit } from "../services/audit.js";
import { buildMetrics } from "../services/metrics.js";
import { buildGrafanaDashboard } from "../services/grafanaDashboard.js";
import { createMetricsToken, publicMetricsToken, resolveMetricsToken } from "../services/metricsTokens.js";
import { asyncHandler } from "../utils/asyncHandler.js";
import { rateLimit } from "../utils/rateLimit.js";
@@ -34,6 +35,14 @@ metricsTokensRouter.use(requireAuth, requireRole("admin"));
const MAX_TOKENS = 10;
// A Grafana dashboard for these series, to import (Dashboards → New → Import). Nothing in it is specific to this installation: Grafana asks which
// Prometheus to use.
metricsTokensRouter.get("/grafana-dashboard.json", asyncHandler(async (_req, res) => {
res.setHeader("Content-Disposition", "attachment; filename=\"homelab-manager-dashboard.json\"");
res.setHeader("Cache-Control", "no-store");
res.json(buildGrafanaDashboard());
}));
metricsTokensRouter.get("/", asyncHandler(async (_req, res) => {
const rows = await db.select().from(metricsTokens).orderBy(metricsTokens.createdAt);
res.json({ tokens: rows.map(publicMetricsToken) });