Handbooks / CI/CD & DevOps / Chapter 5

Monitoring and Rollback

7 pages · ~5 min✓ Reviewed

Builds on Deployment Strategies.

CI/CD & DevOpsPage 1

Logs, Metrics and Traces: The Mental Model

1. Observability vs Monitoring

  • Observability: explain unknown failures from outside, using emitted telemetry
  • Monitoring: checks only known failure conditions

2. The Three Signals

MetricsTracesLogs
IsNumeric time seriesSpans sharing one trace IDTimestamped event records
StrengthCheap, aggregatableFollows one request across servicesDetail on one event
AnswersTHAT it is wrongWHEREWHY
CostCheapest–Highest at volume
  1. Metric alertTHAT
  2. TraceWHERE
  3. Log lineWHY

3. Cardinality Mistake

  • User ID or request ID as a metric label
  • Every value makes a new series: series count and cost explode
  • Put them in logs and traces instead
Remember

Metrics detect, traces locate, logs explain. Keep high-cardinality values out of labels.

CI/CD & DevOpsPage 2

The Four Golden Signals

1. The Four Signals

SignalMeasuresExample
Latencytime to serve a requestp99 of /checkout
Trafficdemandrequests per second
Errorsrate of failed requests5xx, wrong content, too slow
Saturationhow full the tightest resource isCPU, memory, disk, pool, queue depth
  • Minimum dashboard for any user-facing service
  • Track latency for successes and failures separately
  • A fast error response hides real slowness

2. RED vs USE

MethodLettersSuits
REDrate, errors, durationrequest-driven services
USEutilization, saturation, errorsresources: hosts, disks

3. Average Latency Trap

  • Alerting on the mean: averages hide the slow tail
  • Alert on p95 and p99 instead
Mean 120ms, p99 3s

Still means 1 in 100 users waits 3s.

CI/CD & DevOpsPage 3

SLIs, SLOs and Error Budgets

1. SLI, SLO, SLA

TermIsExample
SLImeasured good / valid eventssuccessful requests ÷ total requests
SLOtarget for the SLI over a window99.9% over 30 days
SLAcontract with consequencespenalty if missed

2. Error Budget and Burn Rate

  • Error budget = 100% − SLO
SLODowntime allowed per 30 days
99.9%about 43 min
99.99%about 4.3 min
  • Burn rate = how fast the budget is spent
  • Burn rate 1: budget ends exactly at the window end
  • Burn rate 10: budget empty in a tenth of the window

3. Policy and Mistakes

  • Budget healthy: ship features faster
  • Budget spent: freeze risky releases, fix reliability
  • Internal SLO tighter than the SLA
Never aim for 100%

Unachievable, and each extra nine costs far more. Pick SLIs users feel (errors, latency), not server CPU.

CI/CD & DevOpsPage 4

Alerting That Pages the Right Human

1. Page on Symptoms

  • Alert on symptoms users feel
  • Error rate, latency, SLO burn
  • Not causes: CPU at 80%
  • Page only if a human must act now
  • Rest: ticket or dashboard

2. Burn Rate vs Threshold

ThresholdBurn rate
Tied to SLONoYes
Brief spikeNoisyTolerated
  • Page: 1h and 5m both above ~14x (~2% budget in 1h)
  • Ticket: ~1x slow burn over 3 days
  • Short 5m window: resets fast after recovery
  • for: stops a single blip firing
yaml
alert: HighErrorRate
expr: sum(rate(http_requests_total{code=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) > 0.01
for: 5m
annotations:
  runbook: https://wiki.example.com/runbooks/high-errors

3. Alert Fatigue

Noisy pages

Non-actionable pages get ignored. Every alert needs an owner and a runbook. Delete or demote what nobody acts on.

CI/CD & DevOpsPage 5

Rollback vs Roll Forward and Incident Basics

1. Rollback or Roll Forward

RollbackRoll forward
DoesRedeploy last good versionShip a fix on top
Default whenRecent deploy caused itRollback is unsafe
  • Roll forward: irreversible migration, or data in a new format
  • Roll forward: one-line fix faster than a redeploy
  • Expand/contract migrations and flags keep rollback possible

2. Incident Response

RoleJob
CommanderCoordinates, decides
Ops leadFixes
Comms leadUpdates stakeholders
DeclareSEV1 = full outage; one channel, one timeline

Commands: undo rollout, check status, recent logs, revert commit.

bash
kubectl rollout undo deployment/api
kubectl rollout status deployment/api
kubectl logs deploy/api --since=15m
git revert <sha>

3. Postmortem and Mistakes

  • Blameless: timeline, impact, root cause, contributing factors, what went well
  • Action items need owners and dates; judge the system, not the person
  • Track MTTD detect, MTTA acknowledge, MTTR recover
Mitigate first

Stop impact by rollback, failover or flag before debugging live. An untested rollback, or one skipping the schema change, fails.

CI/CD & DevOpsPage 6

Cheat Sheet: Observability, SLOs and Incidents

1. Signals and SLO math

PillarTells you
MetricsTHAT it broke
TracesWHERE
LogsWHY
  • No user or request IDs in metric labels (cardinality)
  • Golden signals: latency, traffic, errors, saturation
  • Use p95/p99, not the mean
  • Budget = 100% - SLO: 99.9% over 30d is about 43 min, 99.99% about 4.3 min
  • Burn rate 1 spends the whole budget over the window
  • SLA is looser than SLO

2. Alerts and rollback

  • Page on symptoms and SLO burn only
  • 1h and 5m windows both above 14x, plus for:
  • Every page needs a runbook and an owner
bash
kubectl rollout undo deployment/api

rollback by default

  • Roll forward only if rollback is unsafe
  • Expand/contract migrations and feature flags keep rollback open

3. Incident flow

  1. Severitydeclare
  2. Commanderassign
  3. Mitigatefirst
  4. Communicate
  5. Postmortemblameless; MTTD, MTTA, MTTR
  • Outage walk-through? Alert, severity, commander, mitigate, communicate, postmortem
  • New service SLO? Pick a user-facing SLI, set the target from baseline, review
  • Dashboard? Four golden signals plus SLO burn
CI/CD & DevOpsPage 7

Check yourself

A dashboard adds a user_id label to a request counter. You have 1 million users. What breaks?
  • Each label value makes its own time series: about 1M series per metric.
  • Storage and query cost explode. Put user_id in logs or traces.
The SLO is 99.9% over 30 days and you have already had 30 minutes of downtime. Budget left?
  • Budget is about 43 min, so roughly 13 min remain.
  • Another outage that long would exhaust it and trigger a release freeze.
A bad deploy shipped with a migration that dropped a column. Roll back or roll forward?
  • Roll forward: the old version needs the dropped column, so rollback is unsafe.
  • Mitigate first, for example by toggling a flag, then ship the fix.