Skip to content

feat(observability): Prometheus metrics for HTTP requests #169

Description

@chitrank2050

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:

  1. GET /metrics endpoint exposing Prometheus-format metrics
  2. Default metrics: Node.js process stats (memory, CPU, event loop lag)
  3. 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
  4. 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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions