Skip to content

Alert when database errors spike (hourly)

POST
/cron/db-error-spike
curl --request POST \
--url https://example.com/api/cron/db-error-spike

Counts Postgres ERROR/FATAL/PANIC log lines over the last hour through the Supabase Management API logs endpoint. When the count passes DB_ERROR_SPIKE_THRESHOLD_PER_HOUR (default 5,000) it raises one in-portal notification and one owner email, at most once per 6 hours. per_hour is the error count; current_count, previous_count and delta are always null. ok is false when the error count cannot be read (read_failed, never treated as 0), the readings call fails, or the dedup stamp fails. notification.queued only says the fire-and-forget hand-off did not throw. The 6-hour dedup stamp is written only after the owner email is sent: a failed email is reported, leaves marked null so the next hourly run retries, and never fails the call. Protected by CRON_SECRET via the x-cron-secret header. Scheduled hourly by the db-error-spike stage of the hourly-sweeps schedule in .slipstream.json.

Check result

Media type application/json
object
ok
required
boolean
outcome
required
string
Allowed values: below_threshold deduped alert read_failed
current_count
null
previous_count
null
delta
null
per_hour
integer | null
threshold_per_hour
number
notification
object
queued
boolean
error
string
email
object
ok
boolean
error
string
marked
boolean | null

Missing or invalid CRON_SECRET