# Runbook — five common operational scenarios (hub) **Audience:** Operators without the admin UI. **Tools:** [scripts/er-cli.sh](../scripts/er-cli.sh) (recommended) or `curl` + `jq` as in [HTTP_CONTRACTS.md](HTTP_CONTRACTS.md). ```bash export ERROR_RESOLVE_API_KEY="" 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`. ```bash ./scripts/er-cli.sh list-open --project crm --limit 200 ``` **curl equivalent** ```bash 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. ```bash ./scripts/er-cli.sh list-open --q "Redis connection" --limit 500 ``` Use **`export`** for offline analysis: ```bash ./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`. ```bash ./scripts/er-cli.sh resolve 123456789 --note "fixed in release 1.2.3" --assigned-to "oncall" ``` **curl** ```bash 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): ```bash ./scripts/er-cli.sh resolve-by-pattern "Timeout contacting upstream" --dry-run ``` 2. **Execute** ```bash ./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.** ```bash ./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](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](HTTP_CONTRACTS.md)) | --- ## Related - [RUNBOOK_TRIAGE.md](RUNBOOK_TRIAGE.md) — broader triage and deploy notes. - [RUNBOOK_INGEST_DEBUG.md](RUNBOOK_INGEST_DEBUG.md) — sender-side ingest issues. - [RUNBOOK_REPORTER_GOOGLE_TLS.md](RUNBOOK_REPORTER_GOOGLE_TLS.md) — TLS / Google OAuth failures on **reporting** apps (PHP, Guzzle), not hub ingest. - [RUNBOOK_REPORTER_CRM_ERRORMONITORING_VIEW.md](RUNBOOK_REPORTER_CRM_ERRORMONITORING_VIEW.md) — CRM missing view `@errormonitoring/dashboard` (`View.php`), not hub ingest. - [RUNBOOK_REPORTER_CRM_PROCESSMANAGER_VIEW.md](RUNBOOK_REPORTER_CRM_PROCESSMANAGER_VIEW.md) — CRM missing view `@processmanager/dashboard` (`View.php`), not hub ingest.