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
141 lines
7.3 KiB
Markdown
141 lines
7.3 KiB
Markdown
# Runbook — debugging ingest (errors.bitreport.pt)
|
||
|
||
**Audience:** DevOps, on-call, integrators shipping events into the **ingest API**.
|
||
**Prerequisites:** `curl`, optional `jq`, a valid per-project ingest key from the vault/admin UI, and network path to `INGEST_API_BASE`.
|
||
|
||
---
|
||
|
||
## 0. Deploy smoke: `BIT-SMOKE error hub ingest live check` (wdmi-store / CRM)
|
||
|
||
**Symptoms:** Hub incident titled like **`BIT-SMOKE error hub ingest live check`** (ex.: [BIT-931](/BIT/issues/BIT-931), `ERRSIG:0dfffa22f758`) — the application’s post-deploy probe could not complete a successful **`POST /v1/ingest/events`** (or treated the response as failure).
|
||
|
||
**Not the same as** feed/XML upload failures — those hit catalog APIs; see [RUNBOOK_REPORTER_WDMI_FEED_UPLOAD.md](RUNBOOK_REPORTER_WDMI_FEED_UPLOAD.md).
|
||
|
||
**Checks (in order)**
|
||
|
||
1. **From the reporter host** (same egress as the app), run [scripts/examples/ingest_smoke.sh](../scripts/examples/ingest_smoke.sh) with production `INGEST_API_BASE` and the **same** ingest key as the app (read token from a file; avoid shell history).
|
||
2. **URL:** must be the ingest service base (no path suffix in env) — clients append `/v1/ingest/events` themselves (see [clients/php/ErrorReporter.php](../clients/php/ErrorReporter.php), [HTTP_CONTRACTS.md](HTTP_CONTRACTS.md)).
|
||
3. **Credentials:** `Authorization: Bearer <token>` or `X-Api-Key`; key must be **active** and **unexpired** in `er_ingest_keys` (§2).
|
||
4. **HTTP codes:** `401` / `429` / `5xx` / timeouts — use sections below; CRM cURL timeouts are short (e.g. 4s) — slow proxies can fail smokes before the hub responds.
|
||
5. **HTTP 400 from schema validation** should be rare; the hub ignores unknown **event-level** JSON keys and unknown **top-level** keys on the batch object (only `events` is required). Required per event: `schema_version`, `occurred_at`, `level`, `message`.
|
||
6. **Intentional throw smokes (`BIT-SMOKE-*`)** — some reporters POST a deliberate error (e.g. `BIT-SMOKE-WDMI-DIRECT-INGEST`) to prove the pipe works. The ingest API **noise-filters** these when `BIT-SMOKE-` appears in the event `message` or client `stacktrace` (`noise_ruleset_version` from `noisePolicy.ts`; see [ingest-hardening-runbook](operations/ingest-hardening-runbook.md)). Expect `skipped: true` / `rule_id: bitreport_smoke_marker` and **no** new incident. The **deploy live-check failure** title `BIT-SMOKE error hub ingest live check` (exact message; uses a space, not `BIT-SMOKE-`) is filtered the same way from ruleset **1.0.4** onward so ERRCLUSTER loops on that signature stop once production runs the new build. If [BIT-309](/BIT/issues/BIT-309) still reopens after that deploy, treat as **stale nodes or a different root cause** ([BIT-942](/BIT/issues/BIT-942)).
|
||
|
||
**After the root cause is fixed**
|
||
|
||
```bash
|
||
./scripts/er-cli.sh list-open --project wdmi-store --q "ERRSIG:0dfffa22f758"
|
||
./scripts/er-cli.sh resolve <unique_id> --note "ingest smoke restored; verified POST /v1/ingest/events from wdmi-store" --assigned-to "oncall"
|
||
```
|
||
|
||
---
|
||
|
||
## 1. Quick health
|
||
|
||
```bash
|
||
curl -sS "${INGEST_API_BASE}/health"
|
||
# expect: {"status":"ok"}
|
||
```
|
||
|
||
If this fails, treat as **process / proxy / TLS** — not application auth.
|
||
|
||
---
|
||
|
||
## 2. HTTP 401 — `unauthorized` / missing credentials
|
||
|
||
**Symptoms:** JSON like `{ "error": "unauthorized", "message": "Missing ingest credentials …" }` or `Invalid or inactive ingest key`.
|
||
|
||
**Checks**
|
||
|
||
1. **Header present:** send exactly one of:
|
||
- `Authorization: Bearer <plaintext-token>`
|
||
- `X-Api-Key: <plaintext-token>`
|
||
2. **Key state in DB:** key must be `active`, not revoked, not expired (`er_ingest_keys`). A common mistake is rotating the key in the UI but leaving old tokens in systemd/env on senders.
|
||
3. **Wrong environment:** staging token against production base URL (or vice versa).
|
||
|
||
**Sanitized curl (no token in shell history):** read token from a file.
|
||
|
||
```bash
|
||
curl -sS -X POST "${INGEST_API_BASE}/v1/ingest/events" \
|
||
-H "Authorization: Bearer $(cat /run/secrets/er_ingest_token)" \
|
||
-H "Content-Type: application/json" \
|
||
-d '{"events":[{"schema_version":1,"occurred_at":"2026-04-02T12:00:00.000Z","level":"error","message":"auth probe"}]}'
|
||
```
|
||
|
||
---
|
||
|
||
## 3. HTTP 429 — rate limits
|
||
|
||
Two layers:
|
||
|
||
1. **Anonymous IP** — unauthenticated `POST /v1/ingest/events` from an IP is throttled (`INGEST_ANON_IP_MAX` / `INGEST_ANON_IP_WINDOW_MS`). Response includes **`Retry-After`** (seconds).
|
||
2. **Per API key** — after successful auth, limits use `rate_limit_max` / `rate_limit_window_ms` on the key row, else service defaults (`INGEST_RATE_LIMIT_MAX`, `INGEST_RATE_LIMIT_WINDOW_MS`).
|
||
|
||
**What to do**
|
||
|
||
- Back off using `Retry-After`.
|
||
- Fix misconfigured clients (tight loops, duplicate crons).
|
||
- For legitimate bursts, raise per-key limits in DB (or split traffic across keys only if product policy allows).
|
||
|
||
**Metrics:** `er_ingest_requests_total{status_code="429"}` and histogram `er_ingest_request_duration_seconds` — see [OBSERVABILITY_PROMETHEUS.md](OBSERVABILITY_PROMETHEUS.md).
|
||
|
||
---
|
||
|
||
## 4. Events accepted but “wrong” incident / duplicate noise — fingerprints
|
||
|
||
Fingerprinting uses **message normalization** (first line, NFKC, collapsed whitespace) and **location** from `context` (`file_path` / `file`, `line_number` / `line` / `lineno`, or nested `stack_info`). See `ingest-api` `fingerprintPolicy.ts` and `normalize.ts`.
|
||
|
||
**Symptoms**
|
||
|
||
- Same logical bug creates **multiple incidents** because `message` differs slightly (timestamps, IDs in text).
|
||
- **Unexpected grouping** because `context.file_path` is missing or varies per host.
|
||
|
||
**Checks**
|
||
|
||
1. Compare **raw** `message` strings from the sender; normalize mentally (first line only).
|
||
2. Ensure **stable** `context.file_path` (and line) for stack-less errors.
|
||
3. Optionally send an explicit **`fingerprint`** field (max 128 chars) for stable dedup when message text is inherently volatile (document this choice per project).
|
||
|
||
**Verify in hub:** use admin `GET /v1/incidents/:id` or public `recent-errors` with `q=<substring>` after triage key is set.
|
||
|
||
---
|
||
|
||
## 5. HTTP 400 — `schema_version` / `occurred_at`
|
||
|
||
- Only **`schema_version: 1`** is accepted.
|
||
- **`occurred_at`** must parse as valid ISO-8601 (see server validation).
|
||
|
||
```bash
|
||
# Bad: will 400
|
||
curl -sS -w "\n%{http_code}\n" -X POST "${INGEST_API_BASE}/v1/ingest/events" \
|
||
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
|
||
-d '{"events":[{"schema_version":2,"occurred_at":"not-a-date","level":"e","message":"x"}]}'
|
||
```
|
||
|
||
---
|
||
|
||
## 6. HTTP 409 — idempotency conflict
|
||
|
||
When **`Idempotency-Key`** is reused with a **different** JSON body, the API returns **409** `idempotency_conflict`. Use a **new** key or retry the **exact** original payload.
|
||
|
||
---
|
||
|
||
## 7. Noise rules — events “disappear”
|
||
|
||
If the response shows `results[]` entries with `"skipped": true`, the event matched a **noise rule** (`rule_id`, `reason`). This is expected for filtered traffic. Check `noise_filtered_count` and compare with `er_ingest_events_total{outcome="skipped_noise"}` in Prometheus (series also carry `rule_id`).
|
||
|
||
---
|
||
|
||
## 8. OpenAPI / Swagger
|
||
|
||
For interactive inspection (lab only):
|
||
|
||
- `GET ${INGEST_API_BASE}/v1/openapi.json`
|
||
- Browser: `${INGEST_API_BASE}/v1/docs/ui`
|
||
|
||
---
|
||
|
||
## Related
|
||
|
||
- [HTTP_CONTRACTS.md](HTTP_CONTRACTS.md) — full request/response shapes.
|
||
- [RUNBOOK_OPERATIONS.md](RUNBOOK_OPERATIONS.md) — hub-side listing and mutations.
|