# Logs, uptime & incidents

> Catch 5xx spikes, broken routes, and slow queries early with live health signals, execute instant rollbacks safely, and communicate calmly during incidents.

- Canonical: https://exaspark.ai/docs/monitoring-and-incidents/

## Turning live health signals into early warnings

Outages rarely begin as total downtime. They usually start with a quiet early warning — a `2%` API `5xx` uptick right after publishing, database queries creeping past 800ms as tables grow, or a broken OAuth redirect affecting mobile users.

Every published ExaSpark app tracks six live checks inside [Analytics & live health](https://exaspark.ai/docs/analytics/): traffic, frontend latency, accounts and sign-ins, API and functions, database health, and uptime probes. Inspect these signals anytime from Web Studio, the Desktop App, or Mobile Web to catch faults before customers write in.

## Classifying incident severity before touching code

Patching live code in a panic frequently turns a small bug into a full outage. Classify severity first so your first move matches real customer impact.

| Severity | Customer impact | Example | First move |
| --- | --- | --- | --- |
| **SEV-1 Critical** | Site unreachable, sign-in down, or Stripe failing | Uptime red, SSL broken, or `500` on `/checkout` | Roll back Live release immediately; pause Pro ads |
| **SEV-2 High** | Core workflow broken for some users | Mobile booking errors or peak-hour timeouts | Roll back if post-publish; otherwise patch in **Preview** |
| **SEV-3 Moderate** | Secondary feature broken with workaround | CSV export failing or avatar upload bug | Reproduce calmly in **Preview**, test, and ship |
| **SEV-4 Low** | Visual glitch or gradual latency drift | List query climbing from `350ms` to `900ms` | Schedule optimization pass before traffic peaks |

## Reading logs and isolating the failing layer

When someone reports "the app is broken," narrow the issue to the exact layer in under three minutes using your health views.

### HTTP status patterns: 4xx vs 5xx

Status codes immediately pinpoint whether requests fail in validation, permissions, routing, or server code:

- **`400` and `422` spikes.** A UI update started sending missing fields or invalid formats to an API handler.
- **`401` and `403` clusters.** Sessions are dropping or role rules tightened unexpectedly; inspect [Debug auth & CORS](https://exaspark.ai/docs/debug-auth-and-cors/).
- **`404` surges on active URLs.** A renamed route or missing redirect broke bookmarked pages, emails, or ad links.
- **`429` rate limits.** An external API throttled outbound requests because caching or retry backoff is missing.
- **`500`, `502`, and `504` errors.** Unhandled null fields, missing schema columns, or slow queries are crashing the server route.

### Database latency and compute saturation

When multiple routes slow down together, inspect **Database health**. Most latency climbs stem from full-table scans missing indexes (`user_id`, `status`, `created_at`) or unpaginated tables fetching thousands of rows at once.

Watch compute headroom as usage grows: Free and Starter support up to `0.5 CU` database compute, while **Pro** raises headroom to `1.0 CU`. Adding indexes and pagination fixes most bottlenecks cleanly.

Capture a brief snapshot before acting so rollback and debugging stay grounded in facts:

```text
Incident Triage Snapshot
- Time (UTC): 2026-05-14 18:12 UTC
- Severity: SEV-1 (checkout bookings failing)
- Signal: API 5xx jumped 0.0% -> 14.2% on POST /api/bookings
- Last Publish: Release #18 at 18:04 UTC (added promo_code field)
- Rollback target: Release #17 (healthy for 6 days)
- Scope: Customers submitting checkout without a promo code
```

## The calm incident response playbook

Follow one rule during any customer-facing outage: **restore service first, debug second**.

1. **Confirm scope in Analytics & live health** — Check uptime, `5xx` rates, and database latency to separate a single browser cache from a real outage.
2. **Execute one-click rollback if recently published** — Open release history in [Publish & custom domains](https://exaspark.ai/docs/publish/) and restore your last healthy release immediately.
3. **Pause active Pro ads during SEV-1** — If checkout or sign-up is impaired, pause running Google or TikTok campaigns so you never fund clicks to an error page.
4. **Reproduce and fix strictly in Preview** — Hand your triage snapshot to the Agent in **Preview**, add defensive checks or indexes, and confirm clean `200` responses.
5. **Re-publish and watch 15 minutes** — Deploy the verified fix, confirm all six health checks stay green, and verify any interrupted Stripe orders or emails.

> **Example prompt (App):** We rolled back Release #18 after POST /api/bookings returned 500 errors whenever promo_code was omitted, and Analytics showed rising query latency on /admin/bookings. In Preview, make promo_code safely optional with explicit validation returning 400 on invalid codes, add database indexes on bookings(status, created_at), paginate /admin/bookings to 25 rows per page, and log structured server error context without exposing secrets or raw stack traces.

## Communicating with users during and after an outage

Customers forgive brief hiccups far faster than silence. On SEV-1 or SEV-2 events impacting sign-in, bookings, or checkout, state three facts clearly: what broke, whether data and payments are safe, and when you will send the next update.

Verify Stripe first before emailing checkout-affected customers so you can confirm honestly that no duplicate charges occurred.

```text
Initial Update (send within 15–30 minutes of SEV-1/SEV-2)
Subject: Quick update on checkout errors at [App Name]

We are investigating checkout errors that began around 6:05 PM UTC.
Your account data is safe, and we confirmed in Stripe that no duplicate charges occurred.
We restored our previous stable release while verifying a permanent fix.
Next update by 6:45 PM UTC.

---

Resolution Update (send once Live health stays green 15+ minutes)
Subject: Resolved — checkout is back to normal at [App Name]

The checkout issue between 6:05 PM and 6:18 PM UTC is fully resolved.
All services are healthy, and incomplete attempts were not charged.
Reply directly to this email if you need any help completing your order.
```

## Writing a lightweight 10-minute post-mortem

Once metrics stay green, spend ten minutes turning the incident into one permanent safeguard so the same failure cannot repeat.

| Incident pattern | Root cause | Permanent safeguard |
| --- | --- | --- |
| **5xx spike right after Publish** | Unvalidated nullable field or untested schema edit | Smoke-test in **Preview** and follow [Schema migrations safely](https://exaspark.ai/docs/schema-migrations-safely/) |
| **Custom domain unreachable or SSL fails** | Expired domain renewal or bad DNS edit | Enable registrar auto-renew and check [Custom domains & DNS](https://exaspark.ai/docs/custom-domains-and-dns/) |
| **Sudden 401/403 wave after auth change** | Broken callback URL or tightened role rule | Test sign-in and member flows via [Staging & release hygiene](https://exaspark.ai/docs/staging-and-release-hygiene/) |
| **Evening peak slowdowns** | Unindexed filters or huge unpaginated admin lists | Index filter/sort columns and paginate all list endpoints |
| **Checkout stalls on third-party API** | Slow external call lacks timeout or fallback | Add strict timeouts and move non-critical calls off checkout |

> **Note:** Watch the first 15 minutes inside [Analytics & live health](https://exaspark.ai/docs/analytics/) after every publish. Catching a small `5xx` uptick at minute three turns a public outage into a quiet two-minute rollback.

## Next steps

- [Analytics & live health](https://exaspark.ai/docs/analytics/) — Understand all six automatic health panels built into every published app.
- [Staging & release hygiene](https://exaspark.ai/docs/staging-and-release-hygiene/) — Ship schema, auth, and payment changes safely with repeatable release gates.
- [Troubleshooting & errors](https://exaspark.ai/docs/troubleshooting/) — Follow step-by-step recovery guides for runtime, auth, and payment errors.

## From the blog

- [App launch checklist](https://exaspark.ai/blog/app-launch-checklist/) — Run practical reliability checks before sending real customers to your app.
- [App security checklist](https://exaspark.ai/blog/app-security-checklist/) — Harden access controls, secrets, and user data boundaries against incidents.
- [Make your website load faster](https://exaspark.ai/blog/how-to-make-a-website-load-faster/) — Prevent mobile latency spikes before traffic surges hit your pages.
