Skip to content

Exported Metrics

wiki edited this page Sep 4, 2026 · 1 revision

Exported metrics

HTTP

http_requests_total — counter

labels: router, method, path, status

The first thing anyone looks at: request rate, error rate, and the split by endpoint.

sum(rate(http_requests_total{status=~"5.."}[5m])) by (path)

This metric could not exist before the framework's handled event carried the response status. The information existed; nothing carried it.

http_request_duration_seconds — histogram

labels: router, method, path

Latency distribution per route pattern. A series is pre-created when a route is registered, so an endpoint with no traffic yet still appears in the exposition rather than being absent until its first request.

histogram_quantile(0.95,
  sum(rate(http_request_duration_seconds_bucket[5m])) by (le, path))

http_requests_in_flight — gauge

labels: router

Concurrent requests, maintained by middleware — incremented on entry, decremented in a defer, so the pairing holds even if the handler panics.

http_requests_unresolved_total — counter

labels: router, method

Requests that matched no route: 404s and 405s. A rising rate on a method that should not be used is a good early signal of a probe or a client that has drifted.

Process

Sampled every CollectionInterval (5s by default; 0 disables the collector).

rex_uptime_seconds seconds since start
rex_memory_bytes allocated heap
rex_goroutines live goroutines

Framework self-observation

These exist because the two mechanisms this extension depends on are lossy by design, and "the numbers are quietly wrong" is the worst failure a metrics system can have.

rex_metric_series_dropped_total — gauge

labels: vector

Time series folded into the overflow series because a vector hit its cardinality cap. Non-zero means a label is unbounded — alert on it.

rex_metric_series_dropped_total > 0

rex_events_dropped_total — gauge

Events discarded by the event bus because its queue was full. Non-zero means a subscriber is too slow, or the queue is too small for the traffic, and that anything derived from events is now incomplete.

rex_routes_total — counter

labels: router

Registered routes per router. Useful as a deployment sanity check: a drop after a release means routes stopped being registered.

Exposition format

OpenMetrics text, served at /metrics. Label values are escaped per the specification, so a label containing a quote, a backslash or a newline does not corrupt the document.

Registry.WriteOpenMetrics(w) streams; ToOpenMetrics() builds the whole payload in memory first. The endpoint uses the streaming form.

Scrape configuration

scrape_configs:
  - job_name: myapp
    static_configs:
      - targets: ['myapp:9090']

Set the scrape interval above CollectionInterval, or process metrics are scraped more often than they are sampled and you see stair-steps.