# Observability

**I want to know a site of mine is unhealthy before anyone has to tell me.**

> Observability is the means; reliability is the goal. Everything here serves one question: is the site healthy, and will someone know quickly when it isn't?

Observability (is the system healthy?) is distinct from product analytics (what are people doing?). Analytics has its own decision, made outside this standard; [go-live item 13](https://jonashw.dev/reliability/go-live.md) only makes sure it is made at every launch, and keeps health checks out of the counts.

## The four golden signals

For each site, know where to read these. *Source: SRE book, "Monitoring Distributed Systems".*

| Signal | Question | Example for a small site |
|---|---|---|
| Latency | How long do requests take? | Median and slow-request time on the main pages |
| Traffic | How much demand is there? | Requests per hour, and which user agents send them |
| Errors | How many requests fail? | Share of 5xx answers |
| Saturation | How close is it to a limit? | Daily quota used (reads, writes, requests) as a share of the allowance |

On free tiers, saturation is the signal most likely to take a site down without warning.

## Outage tiers

The owner ranks sites by how much a day-long outage would hurt, with pairwise "which would hurt more?" questions. The outage tier sets how closely a site is watched.

| Outage tier | Checks | Alert |
|---|---|---|
| 1 | Uptime every 5 minutes; quota at 50% | Push at high priority, plus email |
| 2 | Uptime every 5 minutes; quota at 50% | Push at normal priority, plus email |
| 3 | Uptime every 15 to 60 minutes | Email, plus a daily push summary |
| 4 | Uptime hourly | Email only |

Each site also gets a one-line SLO. Start loose (for example 99.5% of requests answered in a month) and tighten only when the owner would act on a miss.

## Checks every site gets

- **Uptime:** an external monitor requests the home page and one deeper page.
- **HTTPS:** the certificate is valid and has more than 14 days left, and http redirects to https.
- **Domain:** auto-renew is on; the registrar's expiry date is recorded.
- **robots.txt on every hostname:** on the custom domain and every platform default or old host, the file exists and returns text (not the app's home page), or the host redirects to the canonical domain.

## Alerts

- Alerts reach the owner by **email and phone push**.
- The sender lives **outside the account it watches**. A hook on the same account as the app goes down with the app.
- Prefer an established monitoring service over custom code; write custom checks only for what no service covers, such as a platform's quota counters.
- The checker, its setup and its exit path: [Outside uptime checks](https://jonashw.dev/reliability/uptime-checks.md).

## Instrumentation standard

When a site outgrows simple checks, use **OpenTelemetry** (a CNCF standard) for logs, metrics and traces, so the data is portable between vendors.
