Problem
No runtime metrics exist. We can't answer: "what's our API latency?", "how many 5xx errors per minute?", "which endpoints are slowest?"
Proposed solution
Integrate prom-client with NestJS:
GET /metrics endpoint exposing Prometheus-format metrics
- Default metrics: Node.js process stats (memory, CPU, event loop lag)
- HTTP request metrics via middleware:
http_request_duration_seconds (histogram) — labeled by method, path, status
http_requests_total (counter) — labeled by method, path, status
http_active_requests (gauge) — currently in-flight requests
- Path normalization:
/invoices/uuid → /invoices/:id (prevents high-cardinality labels)
API design
GET /metrics
→ 200
Content-Type: text/plain
"/api/v1/entitlements/:featureKey/check"
Alternatives considered
- StatsD — rejected. Prometheus pull model is simpler for Kubernetes deployments.
- Custom metrics endpoint — rejected. Prometheus format is the industry standard. Every monitoring stack supports it.
Additional context
prom-client is the standard Node.js Prometheus library. Install via pnpm add prom-client.
Problem
No runtime metrics exist. We can't answer: "what's our API latency?", "how many 5xx errors per minute?", "which endpoints are slowest?"
Proposed solution
Integrate
prom-clientwith NestJS:GET /metricsendpoint exposing Prometheus-format metricshttp_request_duration_seconds(histogram) — labeled by method, path, statushttp_requests_total(counter) — labeled by method, path, statushttp_active_requests(gauge) — currently in-flight requests/invoices/uuid→/invoices/:id(prevents high-cardinality labels)API design
Alternatives considered
Additional context
prom-clientis the standard Node.js Prometheus library. Install viapnpm add prom-client.