Files
errors.bitreport.pt/docs/RUNBOOK_OPERATIONS.md
T
Peter Spark 8767e40bb6 docs(ops): hub parity tooling — HTTP contracts, runbooks, Prometheus
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
2026-04-02 20:36:57 +00:00

3.2 KiB

Runbook — five common operational scenarios (hub)

Audience: Operators without the admin UI.
Tools: scripts/er-cli.sh (recommended) or curl + jq as in HTTP_CONTRACTS.md.

export ERROR_RESOLVE_API_KEY="<from vault>"
export ER_API_BASE="https://errors.bitreport.pt"   # or internal Fastify URL

Scenario 1 — List open incidents for a project

Goal: See everything open/investigating for slug crm.

./scripts/er-cli.sh list-open --project crm --limit 200

curl equivalent

curl -sS -G "${ER_API_BASE}/api/error-monitoring/recent-errors" \
  --data-urlencode "api_key=${ERROR_RESOLVE_API_KEY}" \
  --data-urlencode "status=open,investigating" \
  --data-urlencode "project_slug=crm" \
  --data-urlencode "limit=200" | jq '.data[] | {unique_id, project_slug, severity, message}'

Scenario 2 — Search by title/message/fingerprint substring

Goal: Find rows matching a failing dependency or error text.

./scripts/er-cli.sh list-open --q "Redis connection" --limit 500

Use export for offline analysis:

./scripts/er-cli.sh export --state open --format json | jq '.[] | select(.message | test("Redis"; "i"))'

Scenario 3 — Resolve one incident (by occurrence or incident id)

Goal: Close after deploy; unique_id is the numeric id from list-open / recent-errors.

./scripts/er-cli.sh resolve 123456789 --note "fixed in release 1.2.3" --assigned-to "oncall"

curl

curl -sS -X POST "${ER_API_BASE}/api/error-monitoring/resolve" \
  -H "Content-Type: application/json" \
  -H "X-Error-Resolve-Key: ${ERROR_RESOLVE_API_KEY}" \
  -d '{"unique_id":"123456789","resolution_notes":"fixed in release 1.2.3"}' | jq .

Scenario 4 — Bulk resolve by message pattern

Goal: Clear a class of errors after a shared root cause.

  1. Dry run (lists matches, no mutation):
./scripts/er-cli.sh resolve-by-pattern "Timeout contacting upstream" --dry-run
  1. Execute
./scripts/er-cli.sh resolve-by-pattern "Timeout contacting upstream" \
  --note "upstream restored 2026-04-02"

This calls POST /api/error-monitoring/bulk-resolve with message_pattern.


Scenario 5 — Purge resolved incidents (destructive)

Goal: reclaim DB space after retention policy. Always dry-run first.

./scripts/er-cli.sh purge --dry-run
# review would_delete
./scripts/er-cli.sh purge

Current implementation deletes all resolved incidents in one call (no age filter). Plan maintenance accordingly; see HTTP_CONTRACTS.md § purge-resolved.


Extras (same session)

Need Command / endpoint
Snapshot CSV ./scripts/er-cli.sh export --state open --format csv > open.csv
Hub stats + Prometheus gauge refresh GET /api/error-monitoring/stats?api_key=…
Admin drill-down Cookie login + GET /v1/incidents/:id (HTTP_CONTRACTS.md)