Files
errors.bitreport.pt/docs/OBSERVABILITY_PROMETHEUS.md
T
David Santos 23704d2e59
CI / Test api (push) Successful in 54s
CI / Test ingest-api (push) Successful in 57s
CI / Lint and typecheck admin-ui (push) Successful in 1m48s
CI / Validate Docker build (push) Successful in 5m19s
feat(ingest): label er_ingest_events_total skipped_noise by rule_id
Break down noise filter counters per noise policy rule for Prometheus observability.

Paperclip-Agent: David Santos (urlKey david-santos; id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376)
Paperclip-Issue: BIT-26791
Paperclip-Run: cea24469-2886-457d-9f6f-09d83aaf9e4a
2026-07-17 23:01:35 +00:00

4.3 KiB
Raw Blame History

Observability — Prometheus & Grafana (errors.bitreport.pt)

Audience: DevOps, SRE.
Scope: Two processes expose GET /metrics in Prometheus text format:

Service Typical scrape URL Metric prefix (node defaults)
Hub API (api/) http://<hub-host>:3200/metrics er_api_*, plus domain gauges er_*
Ingest API (ingest-api/) http://<ingest-host>:<port>/metrics er_ingest_*

Scrape both targets in Prometheus; use Grafana for dashboards and alerts.


1. Scraping configuration (Prometheus)

Add two static_configs jobs (names are examples):

scrape_configs:
  - job_name: errors_hub_api
    metrics_path: /metrics
    static_configs:
      - targets: ['10.10.50.x:3200']
        labels:
          service: errors_hub
          env: production

  - job_name: errors_ingest_api
    metrics_path: /metrics
    static_configs:
      - targets: ['10.10.50.y:3210']
        labels:
          service: errors_ingest
          env: production

If TLS or auth is fronted by Nginx, scrape the internal listener or enable mTLS/network policy as per your standard.


2. Hub API — key metrics

HTTP traffic

  • er_api_http_requests_total — labels: method, route, status_code.
  • er_api_http_request_duration_seconds — histogram for latency SLOs.
  • er_api_rate_limit_rejections_total — labels: bucket (global, ingest, login, mutation). Increments when @fastify/rate-limit returns 429 (or 403 when ban applies) for that policy. Use alongside status_code="429" on the HTTP counter to alert on abuse vs. organic load.

Domain gauges (refreshed when GET /api/error-monitoring/stats runs)

Automation or Grafana can poll that endpoint on an interval (with read key) to keep gauges warm, or you rely on natural admin/UI traffic.

Metric Labels Meaning
er_incidents_total state Count by open, investigating, resolved, ignored
er_incidents_by_severity severity Count by severity
er_occurrences_last_24h — Occurrence rows in last 24h
er_resolved_last_24h — Distinct incidents resolved in last 24h
er_project_incidents_total project, state Per-project counts
er_project_resolution_rate project Resolved ÷ total (0..1)

Node/process defaults

collectDefaultMetrics runs with prefix er_api_ — includes event loop delay, heap, GC, etc. Use for generic health.


3. Ingest API — key metrics

Metric Labels Meaning
er_ingest_request_duration_seconds status_code End-to-end POST latency (SLO: watch p95/p99)
er_ingest_requests_total status_code Request volume by outcome class
er_ingest_events_total outcome, rule_id stored / error use empty rule_id; skipped_noise sets noise policy id (e.g. resize_observer_loop)
er_ingest_batch_size — Histogram of events per request
er_ingest_active_connections — In-flight requests (gauge)

Plus er_ingest_* process defaults from prom-client.


4. Grafana — starter panels

  1. Ingest availability: sum(rate(er_ingest_requests_total[5m])) by (status_code).
  2. Ingest latency: histogram quantiles on er_ingest_request_duration_seconds (e.g. histogram_quantile(0.95, …)).
  3. Noise vs stored: rate(er_ingest_events_total{outcome="stored"}[5m]) vs skipped_noise. Per-rule noise: sum(rate(er_ingest_events_total{outcome="skipped_noise"}[5m])) by (rule_id).
  4. Open incidents: er_incidents_total by state (after stats refresh).
  5. Hub HTTP errors: sum(rate(er_api_http_requests_total{status_code=~"5.."}[5m])).

5. Linking to the observability “stats” stream

The hub’s GET /api/error-monitoring/stats JSON payload is the operational summary humans use; Prometheus mirrors a subset as gauges when that route is called. For Grafana:

  • Prefer metrics for trends and alerting.
  • Use the JSON endpoint (with api_key) for ad-hoc checks or scripted reports — see HTTP_CONTRACTS.md.