Add canonical HTTP_CONTRACTS with curl for hub + ingest endpoints, operator runbooks for ingest debugging and five common hub flows, and Grafana/Prometheus scraping notes. Extend ERROR_MONITORING_PUBLIC_API with stats + curl examples; align purge and resolve-by-pattern docs with the Fastify implementation. Add optional smoke scripts under scripts/examples/. Paperclip-Agent: 5d084b36-f38f-42a5-a92a-520005afda4f Paperclip-Issue: BIT-736 Paperclip-Run: ad2c5129-df54-44aa-afd4-6f9f7486c1a1 Made-with: Cursor
3.9 KiB
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.
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 |
stored, skipped_noise, error |
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
- Ingest availability:
sum(rate(er_ingest_requests_total[5m])) by (status_code). - Ingest latency: histogram quantiles on
er_ingest_request_duration_seconds(e.g.histogram_quantile(0.95, …)). - Noise vs stored:
rate(er_ingest_events_total{outcome="stored"}[5m])vsskipped_noise. - Open incidents:
er_incidents_totalbystate(after stats refresh). - 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.
Related
- HTTP_CONTRACTS.md — curl examples including
/metrics. - RUNBOOK_INGEST_DEBUG.md — 429 / auth aligned with
er_ingest_*.