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
2.9 KiB
2.9 KiB
Admin API — operational statistics (/v1/stats/*)
Audience: errors.bitreport.pt admin UI, internal dashboards, automation.
Auth: Same as other admin routes — JWT cookie (__Host-access) and permission errors:read.
Base URL: ERROR_REPORTING_ADMIN_API_BASE (Fastify service, typically port 3200 behind /admin/ proxy).
GET /v1/stats/summary
Aggregates over all incidents (current state), optional filter by project.
| Query | Description |
|---|---|
project |
Optional. Project slug; omit for all projects. |
Response
byProject[]: per slug —total(incident count),open,investigating,resolved,ignored,critical(incidents withseverity = critical, any state).bySeverity: global counts keyed by severity.resolvedLast24h: distinct incidents moved toresolvedin the last 24 hours (state history).totalLast24h: occurrence rows in the last 24 hours.
GET /v1/stats/trend
Occurrence counts bucketed by time and severity.
| Query | Description |
|---|---|
granularity |
day (default) or hour. |
days |
With granularity=day: window length, default 30, max 366. |
hours |
With granularity=hour: number of UTC hour buckets ending at the current hour, default 24, max 168. |
project |
Optional project slug. |
Response — daily (granularity=day)
granularity:"day"dates: UTC calendar datesYYYY-MM-DD(inclusive window).series: for each severity, an array of counts aligned withdates.
Response — hourly (granularity=hour)
granularity:"hour"hours: UTC hour bucket labelsYYYY-MM-DD HH:00:00(start of bucket).series: same shape as daily, aligned withhours.
Hourly buckets use CONVERT_TZ(..., @@session.time_zone, '+00:00') so labels match UTC wall-clock when the DB session timezone is configured consistently.
GET /v1/stats/recurrence
Ranks incidents by how many occurrence rows they received in a sliding window (recurrence / noise hotspots).
| Query | Description |
|---|---|
project |
Optional project slug. |
days |
Window length in days, default 7, max 90. |
limit |
Max rows, default 15, max 100. |
Response
windowDays,rangeStart,rangeEndExclusive: bounds used for the query (MySQLDATETIME(6)strings).top[]:id,projectSlug,fingerprint,title,severity,currentState,hitsInWindow,lifetimeOccurrences.
Indexes
Heavy queries use:
er_incident_occurrences (project_id, occurred_at DESC)— filtered trends and recurrence by project.er_incident_occurrences (occurred_at DESC)— global time-range scans (see migration20260402103000_add_occurred_at_for_stats).
Related
- Curl examples (cookie login +
/v1/stats/*):docs/HTTP_CONTRACTS.md. - Public ingest /
recent-errors:docs/in this repo and PaperclipERROR_REPORTING_HUB_CONTRACT.md.