Monitoring & SRE
Site reliability engineering — SLIs, SLOs and error budgets, the golden signals, monitoring stacks (Prometheus, Grafana, OpenTelemetry), alerting on symptoms, on-call and incident response, blameless postmortems, toil reduction and capacity planning.
Site Reliability Engineering (SRE), pioneered at Google, applies software engineering to operations: define reliability targets precisely, measure them, automate away manual work, and balance reliability against the speed of shipping features. (Metrics, logs and traces themselves are covered in Observability.)
SLIs, SLOs and SLAs
| Term | Definition | Example |
|---|---|---|
| SLI — indicator | A measured ratio of good events to total events | % of HTTP requests that succeed in under 300 ms |
| SLO — objective | The target for an SLI over a window | 99.9% of requests over 28 days |
| SLA — agreement | A contract with customers, with penalties | 99.5% monthly uptime or service credits |
SLOs should be stricter than SLAs, so you notice problems before they cost money. Choose SLIs that reflect user experience — availability and latency measured at the load balancer or client, not CPU usage.
Error budgets
An SLO of 99.9% means you're allowed 0.1% failure — the error budget.
| SLO | Allowed downtime per 30 days |
|---|---|
| 99% | 7.2 hours |
| 99.9% | 43.2 minutes |
| 99.95% | 21.6 minutes |
| 99.99% | 4.3 minutes |
| 99.999% | 26 seconds |
The budget turns reliability debates into data: budget remaining → ship features faster, take risks; budget exhausted → freeze risky launches and invest in reliability. 100% is the wrong target — it's impossibly expensive, and users can't tell the difference beyond what their own networks deliver.
Each extra nine also costs roughly 10× more effort: redundancy across zones and regions, automated failover, careful rollouts.
What to monitor: the golden signals
| Signal | Question |
|---|---|
| Latency | How long do requests take? (Track successful and failed separately; use percentiles — p50, p95, p99 — not averages) |
| Traffic | How much demand? (requests/s, messages/s) |
| Errors | What fraction fails? (explicit 5xx, wrong content, too slow) |
| Saturation | How full is the system? (CPU, memory, queue depth, connection pool, disk) |
Related frameworks: RED for services (Rate, Errors, Duration) and USE for resources (Utilisation, Saturation, Errors).
The monitoring stack
Commercial all-in-one alternatives: Datadog, New Relic, Honeycomb, Grafana Cloud, cloud-native tools (CloudWatch, Cloud Monitoring).
# Error ratio over 5 minutes
sum(rate(http_requests_total{job="api", status=~"5.."}[5m]))
/ sum(rate(http_requests_total{job="api"}[5m]))
# p99 latency from a histogram
histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket{job="api"}[5m])))Alerting
Bad alerting burns people out: pages for things that don't matter, or that fix themselves, train responders to ignore pages.
- Alert on symptoms, not causes: page when users are affected (SLO burn), not when a CPU hits 80%.
- Every page must be urgent, actionable, and require a human — otherwise make it a ticket or a dashboard.
- Burn-rate alerts: page when the error budget is being consumed fast enough to exhaust it soon.
| Burn rate | Budget consumed | Window | Action |
|---|---|---|---|
| 14.4× | 2% in 1 hour | 1 h (with 5 min short window) | Page |
| 6× | 5% in 6 hours | 6 h | Page |
| 1× | 10% in 3 days | 3 d | Ticket |
- Link each alert to a runbook: what it means, how to diagnose, how to mitigate.
- Synthetic monitoring (probing endpoints from outside) catches total outages your internal metrics miss.
On-call and incident response
A sustainable on-call rotation: enough people (at least 6–8 for 24/7), handover notes, compensation, and a target of only a few pages per shift.
During an incident:
- Declare it and assign roles: incident commander (coordinates, decides), operations/subject experts (investigate and act), communications lead (status page, stakeholders), scribe.
- Mitigate first, find root cause later: roll back the last deploy, fail over, shed load, disable a feature flag. Restoring service beats understanding it.
- Communicate regularly on a set cadence, internally and on the status page.
- Resolve, then monitor for recurrence.
Severity levels (SEV1 = major customer impact … SEV4 = minor) decide who gets involved and how fast.
Blameless postmortems
After significant incidents, write a postmortem:
- Timeline, impact (users, duration, error budget spent), detection, response, root cause(s) and contributing factors.
- What went well, what went poorly, where we got lucky.
- Action items with owners and due dates — preventing recurrence, improving detection and speeding up mitigation.
Blameless means focusing on systems and processes, not individuals: "the deploy tool allowed pushing an unreviewed config to all regions at once", not "Ravi pushed a bad config". People hide information when they fear blame; you need that information to fix the system. Techniques like the "5 whys" help, but real incidents usually have multiple contributing causes.
Toil and automation
Toil is manual, repetitive, automatable operational work that scales with the service and has no lasting value (manually restarting services, provisioning accounts by hand, copy-paste deploys). Google's SRE guideline: keep toil under 50% of an SRE's time and spend the rest on engineering that removes it — self-healing systems, automation, better tooling.
Capacity planning and resilience testing
- Forecast demand (organic growth, launches, seasonal peaks like sales events) and provision headroom; load test before big events.
- Autoscaling handles short-term variation; capacity planning handles quotas, reserved capacity and limits that can't scale instantly.
- Chaos engineering: deliberately inject failures (kill instances, add latency, fail a zone) in controlled experiments to verify the system degrades gracefully — Chaos Monkey, Gremlin, AWS FIS. Game days rehearse incident response.
- Disaster recovery drills: actually restore from backups and fail over regions on a schedule.
- SLIs measure user-visible behaviour; SLOs set targets; SLAs are contracts — SLOs stricter than SLAs.
- Error budgets balance reliability and feature velocity; 100% is the wrong target.
- Monitor the golden signals: latency (percentiles), traffic, errors, saturation.
- Alert on symptoms and SLO burn rate; every page actionable, with a runbook.
- In incidents, assign roles and mitigate first; afterwards write blameless postmortems with owned action items.
- Reduce toil through automation; plan capacity; test resilience with chaos engineering and DR drills.
QWhat is an error budget and how is it used?medium
It's the amount of unreliability an SLO permits — for a 99.9% availability SLO over 30 days, about 43 minutes of failure. Teams track how much has been consumed. With budget left, they can ship faster and take risks; when it's exhausted, they pause risky releases and prioritise reliability work. This aligns product and operations around a shared, measurable target instead of arguing about stability versus speed.