How are health, logs, and metrics exposed and collected? #58
Notifications
Due Date
No due date set.
Depends on
Reference: bobby/hapi#58
Reference in new issue
Block a user
Part of #44
Question
What health endpoints does hAPI expose (liveness, readiness, dependency checks) and how does the external Uptime Kuma reach them (pull over which network, or push monitors)? Which stack collects logs and basic metrics, where does it run, and how is it accessed?
Inputs from Which libraries and conventions form the FastAPI app skeleton?: the app emits structlog JSON to stdout with
request_id/principal_idbound and Personal data redacted;/healthzand/readyzsit outside/v1; one uvicorn process per pod.Constraint from How is hAPI reachable on the network? (ADR-0002): there are no anonymous public endpoints, so Uptime Kuma probes as a Bot with a health-only scope (token in a custom header). Metrics and detailed health are never public.
Input from How does hAPI connect to its managed database? (#53, ADR-0004):
hapi db breakglassemits structured audit events (start, end, reason, every statement, never results) to centralized logs. The platform has no DB statement logging, so the log pipeline is the only audit trail. Its retention and tamper-resistance matter for these events.Note from How do Principals authenticate, and what may each do? (ADR-0005): Uptime Kuma is a Bot holding the
healthScope, and ADR-0002 allows no anonymous public endpoints. This ticket needs to square that with kubelet liveness and readiness probes, for example by serving probes on a separate internal port that the Gateway never routes.Input from Which bridge carries jobs to Home Assistant? (ADR-0006): hAPI records the time of Home Assistant's last poll of
GET /v1/smart_home/jobs/next(normally every 15–30 s). This ticket decides whether and how that becomes a health signal, e.g. a Kuma check that fails when there's been no poll for 5 min.Inputs from How do code changes reach the cluster? (#56, ADR-0007): log, metrics, and health components arrive as Flux
HelmReleases underdeploy/infrastructure. Flux exposes its own reconcile metrics and conditions. Failed migrate Jobs and stalled rollouts are among the deploy failures worth surfacing, and alerting on them goes to ntfy (see the Notifications fog on the map).Resolution
Recorded as ADR-0009.
:8000serves the API and is the only port the Gateway routes.:8081is internal, never routed, and limited by NetworkPolicy to kubelet and the scraper. It serves/livez,/readyzand/metricswithout auth, from the same process and event loop as the API. This replaces the skeleton's public/healthz//readyz(from Which libraries and conventions form the FastAPI app skeleton?)./livezreturns a constant (it proves the loop is turning)./readyzmeans startup is done and does not check the DB. On SIGTERM, readiness fails first, then about 5 s of drain.GET /v1/healthneeds thehealthScope and returnsok,degradedordownwith only check names andok/fail. Critical checks aredbandschema; if either fails, the status isdownwith HTTP 503. Non-critical checks areha_bridge(no HA poll for 5 min) andjob_backlog; if one fails, the status isdegradedwith HTTP 200. Uptime Kuma, a Bot on its own public VM, runs two monitors: up (HTTP status) and healthy (JSON querystatus == "ok").monitoringnamespace on Block Storage PVs, delivered by Flux. vmagent scrapes the app, kubelet/cAdvisor, kube-state-metrics, node-exporter, Flux and Cilium. Vector takes pod logs and Talosmachine.logging, and an event exporter ships Kubernetes Events.prometheus-client: route template, status, latency, pool usage, Jobs, HA poll age and auth failures. There is noprincipal_idor Personal data in labels.kubectl port-forwardover the management tailnet. Telemetry and update checks are off, and plugins are pinned. Outbound traffic frommonitoringis denied except vmalert → ntfy and the Watchdog → Kuma push.Left to implementation: the
job_backlogthreshold and the exact vmalert rules. ntfy topics, routing and auth remain in the Notifications fog.