import type { Metadata } from "next"; import Link from "next/link"; import { RelativeTime } from "@/components/ui/freshness"; import { Empty, Page, PageHeader, Section, Stat } from "@/components/ui/section"; import { Sparkline } from "@/components/ui/sparkline"; import { StatusBadge } from "@/components/ui/status-badge"; import { api } from "@/lib/api"; import { formatDateTime, formatDuration } from "@/lib/format"; import type { DataHealth } from "@/lib/types"; export const metadata: Metadata = { title: "Data health", description: "Live health of Market Atlas' observation network: connector states, freshness, multi-source coverage, confidence and incidents.", alternates: { canonical: "/data-health" } }; export const dynamic = "force-dynamic"; export default async function DataHealthPage() { const h = await api("/v1/data-health"); const c = h.connectors; return ( Public status →} />
{c.healthy} healthy {c.degraded} degraded / stale {c.recovering} recovering {c.failed} failed {c.paused} paused
{h.history.length > 1 && (
x.healthy_ratio)} fmt={(v) => `${Math.round(v * 100)}%`} /> x.messages)} fmt={(v) => Math.round(v).toLocaleString("en-US")} /> x.latency_ms ?? 0)} fmt={(v) => formatDuration(v)} />
)}
{h.by_connector.map((r) => ( ))}
Connector State Msg / min Median latency Instruments Reliability Last message Last error
{r.id} {r.messages_1m} {r.median_latency_ms == null ? "—" : formatDuration(r.median_latency_ms)} {r.instruments} {r.reliability_score ?? "—"} {r.last_message_at ? : "—"} {r.last_error ?? "—"}
{h.incidents.length ? (
    {h.incidents.map((i) => (
  • {formatDateTime(i.ts, { seconds: true })} {i.title} {i.type}
  • ))}
) : ( No source incidents in the last 7 days. )}
); } function Trend({ label, values, fmt }: { label: string; values: number[]; fmt: (v: number) => string }) { const last = values[values.length - 1] ?? 0; return (
{label}
{fmt(last)}
); }