---
id: w3/m2/t003
title: Request-metrics backend (Traefik Prometheus)
worker: worker3
status: done
estimate: 45m
depends_on: [w3/m2/t001]
---

## Objective

Source per-App request metrics — request count, latency percentiles (p50/p90/p99), status codes, and outbound bytes — from Traefik's Prometheus metrics.

## Context

- Traefik exposes per-router Prometheus metrics (`traefik_router_requests_total`, `traefik_router_request_duration_seconds_bucket`, response bytes). An App maps to a Traefik router via its ingress (`docs/ADR005-custom-domain.md`, `operator/internal/controller/hosts_test.go`).
- Percentiles come from the histogram buckets; bandwidth from the bytes counters.
- Risk: Traefik metrics must be enabled and scrapeable; querying may need a Prometheus (or reading Traefik's metrics endpoint directly for instant values). Record the chosen approach in `docs/ADR010-observability.md`.

## Steps

1. Add request-metric methods to the metrics backend (t001) that read Traefik metrics for the App's router(s).
2. Aggregate request count, latency percentiles from buckets, status-code breakdown, and outbound bytes over the time range.
3. Document the metrics source (direct scrape vs Prometheus) in `docs/ADR010-observability.md`.

## Files

- `operator/internal/api/metrics.go`, `docs/ADR010-observability.md`

## Acceptance criteria

- [ ] Backend returns request count, p50/p90/p99 latency, status-code breakdown, and outbound bytes for an App.
- [ ] Metrics source and query approach documented.

## Out of scope

- REST/GraphQL adapters (t004), enabling Traefik metrics in-cluster (t005/platform).
