Admin Alerting Setup (onset-web)¶
This config evaluates Supabase admin metrics and routes alerts to SendGrid, Slack, and/or PagerDuty.
Endpoint¶
POST /api/admin/alerts- Header:
Authorization: Bearer <ONSET_ADMIN_ALERTS_TOKEN> - Optional query:
?dry_run=1(evaluate thresholds without sending notifications)
Required Environment Variables¶
Core:
ONSET_ADMIN_ALERTS_TOKENSUPABASE_URLSUPABASE_ANON_KEYADMIN_DASHBOARD_SECRETSENDGRID_API_KEY
Destinations:
ALERT_EMAIL_TO(comma-separated, e.g.ops@theonset.app,founder@theonset.app)ALERT_SLACK_WEBHOOK_URL(optional)PAGERDUTY_ROUTING_KEY(optional)
Threshold overrides (optional):
ALERT_MAX_SECURITY_EVENTS_24H(default50)ALERT_MAX_FLAGGED_24H(default5)ALERT_MIN_PAYWALL_SHOWN_24H(default20)ALERT_MIN_CONVERSION_RATIO(default0.02)
GitHub Actions Scheduler¶
Workflow: .github/workflows/admin-alert-check.yml
Set GitHub secrets in onset-web repo:
ONSET_WEB_BASE_URL(e.g.https://theonset.app)ONSET_ADMIN_ALERTS_TOKEN
The workflow runs weekly (Sunday at 19:00 UTC) and calls /api/admin/alerts.
Email cadence controls (optional, defaults shown):
ALERT_EMAIL_WEEKLY_SUNDAY_ONLY=trueALERT_EMAIL_WEEKLY_DAY_UTC=0(0=Sunday)ALERT_EMAIL_WEEKLY_TIME_ENFORCED=trueALERT_EMAIL_WEEKLY_HOUR_UTC=19ALERT_EMAIL_WEEKLY_MINUTE_UTC=0
With these defaults, email sends only once per week at Sunday 19:00 UTC, avoiding repeated alerts throughout Sunday.
Manual Test¶
Dry run:
curl -sS -X POST "https://theonset.app/api/admin/alerts?dry_run=1" \
-H "Authorization: Bearer $ONSET_ADMIN_ALERTS_TOKEN" \
-H "Content-Type: application/json"
Live run: