merge: BIT-736 operational tooling — HTTP contracts, runbooks, Prometheus docs
Paperclip-Issue: BIT-736
This commit is contained in:
commit
c8adcac393
9 files changed
+869
-2
No files matched your search
@@ -2,9 +2,12 @@
|
||||
|
||||
CRM-shaped JSON endpoints served by the Fastify API (`@errors-bitreport/api`). Same paths as the CRM `ErrorMonitoring` module where noted.
|
||||
|
||||
**Canonical HTTP shapes + curl cookbook:** [`docs/HTTP_CONTRACTS.md`](../../docs/HTTP_CONTRACTS.md) (repo root).
|
||||
**Operator runbooks:** [`docs/RUNBOOK_OPERATIONS.md`](../../docs/RUNBOOK_OPERATIONS.md), [`docs/RUNBOOK_INGEST_DEBUG.md`](../../docs/RUNBOOK_INGEST_DEBUG.md).
|
||||
|
||||
## Authentication
|
||||
|
||||
### Read (`GET …/recent-errors`)
|
||||
### Read (`GET …/recent-errors`, `GET …/stats`)
|
||||
|
||||
- Query: `api_key` must match `ERROR_RESOLVE_API_KEY` or `ERROR_REPORTING_API_KEY`, **or**
|
||||
- Query: `view_errors` must match `DEBUG_VIEW_ERRORS_KEY`.
|
||||
@@ -18,6 +21,18 @@ CRM-shaped JSON endpoints served by the Fastify API (`@errors-bitreport/api`). S
|
||||
- `errors:delete` for purge-resolved
|
||||
- If no resolve key is configured → only session auth is accepted (token-only automation is disabled).
|
||||
|
||||
## `GET /api/error-monitoring/stats`
|
||||
|
||||
Hub operational summary (24h ingestion, severity/state counts, per-project rollups). **Also** refreshes Prometheus gauges on the API process (best-effort).
|
||||
|
||||
**Auth:** Same query keys as `recent-errors` (`api_key` or `view_errors`).
|
||||
|
||||
**Example**
|
||||
|
||||
```bash
|
||||
curl -sS -G "${ER_API_BASE}/api/error-monitoring/stats" --data-urlencode "api_key=${ERROR_RESOLVE_API_KEY}"
|
||||
```
|
||||
|
||||
## `GET /api/error-monitoring/recent-errors`
|
||||
|
||||
Alias: `GET /v1/paperclip/recent-errors`
|
||||
@@ -36,6 +51,16 @@ Alias: `GET /v1/paperclip/recent-errors`
|
||||
|
||||
Each row includes CRM-compatible fields. For non-resolved incidents, `status` is always `"open"` (including `investigating`) so Paperclip `error_loop` continues to treat rows as open.
|
||||
|
||||
**Example**
|
||||
|
||||
```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=50"
|
||||
```
|
||||
|
||||
## `POST /api/error-monitoring/resolve`
|
||||
|
||||
**Body (JSON):**
|
||||
@@ -49,6 +74,15 @@ Each row includes CRM-compatible fields. For non-resolved incidents, `status` is
|
||||
|
||||
**Responses:** **200** success envelope; **400** missing id; **401** auth; **404** not found or not resolvable; **503** if read keys not applicable (mutations use resolve key / session only).
|
||||
|
||||
**Example**
|
||||
|
||||
```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":"12345","resolution_notes":"verified in prod"}'
|
||||
```
|
||||
|
||||
## `POST /api/error-monitoring/bulk-resolve`
|
||||
|
||||
**Body (JSON):**
|
||||
@@ -63,6 +97,15 @@ Each row includes CRM-compatible fields. For non-resolved incidents, `status` is
|
||||
|
||||
If both `unique_ids` and `message_pattern` are sent, **`unique_ids` wins** (CRM behaviour).
|
||||
|
||||
**Example (pattern)**
|
||||
|
||||
```bash
|
||||
curl -sS -X POST "${ER_API_BASE}/api/error-monitoring/bulk-resolve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Error-Resolve-Key: ${ERROR_RESOLVE_API_KEY}" \
|
||||
-d '{"message_pattern":"Connection refused","resolution_notes":"dependency restored"}'
|
||||
```
|
||||
|
||||
## `POST /api/error-monitoring/resolve-by-pattern`
|
||||
|
||||
Bulk resolve incidents matching one or more advanced filters. At least one filter is required.
|
||||
@@ -95,7 +138,16 @@ Bulk resolve incidents matching one or more advanced filters. At least one filte
|
||||
| `older_than_days` | Non-negative integer; only purge resolved incidents with `last_seen_at` older than this many days. If omitted, purges all resolved. |
|
||||
| `api_key` | Optional resolve key |
|
||||
|
||||
**Effect:** `DELETE` from `er_incidents` where `current_state = 'resolved'` (cascades occurrences and related rows per schema).
|
||||
**Effect:** `DELETE` from `er_incidents` where `current_state = 'resolved'` (cascades occurrences and related rows per schema). **All** resolved incidents are removed when `dry_run` is false — there is no age filter in the current handler.
|
||||
|
||||
**Example**
|
||||
|
||||
```bash
|
||||
curl -sS -X POST "${ER_API_BASE}/api/error-monitoring/purge-resolved" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Error-Resolve-Key: ${ERROR_RESOLVE_API_KEY}" \
|
||||
-d '{"dry_run":true}'
|
||||
```
|
||||
|
||||
## Admin UI proxy
|
||||
|
||||
|
||||
Reference in new issue
Block a user