> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shikshaos.triverseinfotech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# alerting-policy

# Error Alerting Policy

## Sentry alert rules (configure in Sentry dashboard)

### 1. Error rate spike — critical

**Trigger:** > 10 new errors in 5 minutes<br />**Action:** Email + Slack #alerts<br />**Query:** `level:error environment:production`

### 2. New issue — high severity

**Trigger:** Any new issue with level = `fatal` or `error`<br />**Action:** Email immediately<br />**Filter:** `environment:production`

### 3. Performance regression — p95 latency

**Trigger:** p95 transaction duration > 3000ms for `/api/*`<br />**Action:** Email

### 4. Cron job failure

**Trigger:** Any error in transaction `GET /api/cron/*`<br />**Action:** Email<br />**Note:** Vercel Cron fires at 2:30 UTC and 13:30 UTC daily

### 5. Auth errors

**Trigger:** > 5 events matching `supabase.auth` in 10 minutes<br />**Action:** Slack #security-alerts

***

## Sentry configuration (already in codebase)

`sentry.server.config.ts`, `sentry.client.config.ts`, `sentry.edge.config.ts` — Sentry is wired.

To add environment tagging, update `sentry.server.config.ts`:

```ts theme={null}
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  environment: process.env.SENTRY_ENVIRONMENT ?? process.env.NEXT_PUBLIC_APP_VERSION ?? "production",
  tracesSampleRate: process.env.NODE_ENV === "production" ? 0.1 : 1.0,
  // Only sample 10% of traces in production to stay within quota
});
```

## Uptime monitoring

Use the `/api/health` endpoint with an external monitor:

| Service      | Free tier                   | Setup                                                                  |
| ------------ | --------------------------- | ---------------------------------------------------------------------- |
| UptimeRobot  | 50 monitors, 5-min interval | Add HTTP monitor → `https://shikshaos.triverseinfotech.com/api/health` |
| BetterUptime | 10 monitors, 3-min interval | Same URL, alert on non-200                                             |

Alert condition: HTTP status ≠ 200 OR response contains `"status":"error"`.

## On-call rotation

Since this is a single-team product, a simple escalation path:

1. **Automated alert** fires → Slack/email
2. No ack in 15 min → WhatsApp to primary dev
3. No ack in 30 min → call secondary dev

Suggested tool: PagerDuty free tier (1 on-call user, unlimited alerts).

## Incident runbook

1. Check `/api/health` → identify failing component
2. Check Vercel Functions logs for the affected route
3. Check Supabase dashboard → Database → Logs for DB errors
4. If DB: check connection pool usage (Supabase → Database → Connection Pooling)
5. Roll back last deploy if needed: Vercel dashboard → Deployments → Promote previous
