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
4.5 KiB
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.
1. Quick health
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
- Header present: send exactly one of:
Authorization: Bearer <plaintext-token>X-Api-Key: <plaintext-token>
- 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. - Wrong environment: staging token against production base URL (or vice versa).
Sanitized curl (no token in shell history): read token from a file.
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:
- Anonymous IP — unauthenticated
POST /v1/ingest/eventsfrom an IP is throttled (INGEST_ANON_IP_MAX/INGEST_ANON_IP_WINDOW_MS). Response includesRetry-After(seconds). - Per API key — after successful auth, limits use
rate_limit_max/rate_limit_window_mson 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.
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
messagediffers slightly (timestamps, IDs in text). - Unexpected grouping because
context.file_pathis missing or varies per host.
Checks
- Compare raw
messagestrings from the sender; normalize mentally (first line only). - Ensure stable
context.file_path(and line) for stack-less errors. - Optionally send an explicit
fingerprintfield (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: 1is accepted. occurred_atmust parse as valid ISO-8601 (see server validation).
# 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.
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 — full request/response shapes.
- RUNBOOK_OPERATIONS.md — hub-side listing and mutations.