Alert when database errors spike (hourly)
const url = 'https://example.com/api/cron/db-error-spike';const options = {method: 'POST'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/cron/db-error-spikeCounts 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.
Responses
Section titled “ Responses ”Check result
object
object
object
Missing or invalid CRON_SECRET