4d520ab0e3
- jellyfin-service-registry: proposal, design, and tasks for completing the Jellyfin migration off machine-level config. - grafana-prometheus-polish: proposal, design, and tasks for improving the Grafana/Prometheus observability integration. Both are planning-only artifacts; implementation not started.
3.4 KiB
3.4 KiB
Design — Grafana/Prometheus integration polish
Change: grafana-prometheus-polish
Phase: design
Date: 2026-06-23
Current state
- Backend integrations:
integrations/grafana.py(configbase_url, secretapi_key, widgetlink) andintegrations/prometheus.py(configbase_url, secretapi_key, widgetmetric). - Backend widget sources:
widgets/sources.pyhasGrafanaWidgetSourceandPrometheusWidgetSource. - Frontend
SERVICE_REGISTRY(frontend/src/integrations/registry.ts) mirrors those widget kinds. - Observability page (
frontend/src/components/ObservabilityPage.tsx) uses hard-codedVITE_GRAFANA_URLfor Grafana links and shows only Alertmanager + Prometheus targets. - Monitoring router (
backend/src/media_library_viewer_api/routers/monitoring.py) exposes/alerts,/alertmanager-status,/alertmanager-webhook,/prometheus-targets,/machines.
Target state
Backend
-
New health endpoints
GET /api/monitoring/grafana-status— probesGET {base_url}/api/health(no auth needed for health) and returns{up, version, error?}.GET /api/monitoring/prometheus-status— probesGET {base_url}/-/healthyand returns{up, version, error?}.- If multiple instances of a type exist, probe the first enabled instance and include its
service_id+namein the response. - If no instance is configured, return
up: false, error: "no_service_configured".
-
New widget kinds
- Grafana: add
explore_linkkind with configquery(optional),datasource(optional). Renders a deep-link to/explore?orgId=1&left={...}or similar. - Prometheus: add
range_chartkind with configpromql,step(e.g.1m),range_seconds(e.g.3600). Renders{ series: [{ timestamp, value }] }for the frontend to chart. The adapter performs a range query (/api/v1/query_range) and reshapes the result.
- Grafana: add
-
Source adapters
- Extend
GrafanaWidgetSource.fetchto handleexplore_link. - Extend
PrometheusWidgetSource.fetchto handlerange_chart.
- Extend
Frontend
-
Observability page
- Replace hard-coded
GRAFANA_BASE_URLwith discovery fromuseServiceInstances("grafana"). - Add
useGrafanaStatus()andusePrometheusStatus()hooks using the new endpoints. - Add health cards for Grafana and Prometheus next to Alertmanager.
- Grafana links (alerts panel, targets panel) use the discovered instance URL.
- Replace hard-coded
-
Widget registry
- Add
explore_linktoSERVICE_REGISTRY.grafana.widgets. - Add
range_charttoSERVICE_REGISTRY.prometheus.widgets. - Add presentational components
GrafanaExploreLinkWidgetandPrometheusRangeChartWidget(or extend existing components).
- Add
-
Types
- Add status response types and widget config types.
Docs
- Update
docs/REQUIREMENTS.mdobservability section to describe service-instance-driven Grafana/Prometheus status and new widget kinds. CHANGELOG.mdadded/changed note.
Slices
- Backend health endpoints + widget kind extensions.
- Frontend Observability page + widget registry + new components.
- Docs + changelog.
Risks
- Grafana Explore URL encoding is version-dependent. Target Grafana 10+ and document the assumption.
- Prometheus range queries can be expensive; cap
range_secondsin the adapter (e.g. max 24h) and use a modeststep. - Multiple Grafana/Prometheus instances: keep it simple — use the first enabled instance for status; widgets already bind to a specific service instance.