Vertical SaaS · Sre

Runbook Automation — A Field Guide

Turning incident runbooks from static documents into executable automation, and where full auto-remediation is worth the risk versus where a human should stay in the loop.

John Kihiu12 min read

A runbook that lives as a wiki page is a bet that whoever's on call at 3am will read it carefully, follow it exactly, and not make a transcription error typing commands under pressure — a bet that loses often enough to be worth automating away. Runbook automation turns the steps a human would type into a script or a tool an on-call engineer triggers directly, which doesn't just save time; it removes the specific failure mode of a tired human fat-fingering a production command during an actual incident.

Automate diagnosis before remediation

The lowest-risk, highest-value place to start is the diagnostic steps every incident begins with: pull the last hour of error rates, check the deploy history for the affected service, grab recent logs matching the alert's signature, confirm which downstream dependencies are healthy. None of this changes production state, so the blast radius of a bug in the automation is "wasted a few seconds," not "made the incident worse." Teams that automate diagnosis first build trust in the tooling before ever asking it to touch anything that could make things worse.

BASH · DIAGNOSTIC RUNBOOK STEP
#!/usr/bin/env bash
# runbook: high-error-rate-checkout-service
echo "=== Recent deploys ==="
kubectl rollout history deployment/checkout-service --namespace prod | tail -5
echo "=== Error rate, last 30m ==="
curl -s "$METRICS_URL/query?q=rate(http_requests_total{service='checkout',status=~'5..'}[30m])"
echo "=== Downstream health ==="
for svc in payments inventory pricing; do
  curl -s -o /dev/null -w "%{http_code} $svc\n" "http://$svc.internal/healthz"
done

Remediation with a human still pressing the button

The next tier is remediation actions packaged as a single command instead of a multi-step manual procedure — roll back the last deploy, restart a specific pod, drain a connection pool, fail over to a replica — triggered explicitly by the on-call engineer rather than firing automatically. This is where most mature teams land for anything with real customer impact: the automation removes typo risk and the cognitive load of remembering exact syntax under pressure, while the human still decides whether the specific remediation is the right call for this specific incident.

Every automated remediation needs a dry-run mode

A rollback or failover script should support a flag that prints exactly what it would do without doing it — useful for a nervous on-call engineer double-checking during a real incident, and essential for testing the runbook automation itself in a non-production environment before trusting it in one.

Full auto-remediation only for narrow, well-understood, low-risk failures

Fully automatic remediation — no human trigger at all — is worth building only for failure modes that are extremely well understood, happen often enough to justify the engineering investment, and have a low-risk, easily-reversible fix: auto-restarting a pod that fails a health check three times in a row, auto-scaling on a clear resource metric, auto-clearing a known-safe cache key pattern. The moment the remediation could plausibly make things worse under some condition you haven't fully enumerated, keep a human in the loop — the failure mode of an auto-remediation system confidently taking the wrong action at 3am, with nobody watching, is worse than a slightly slower manual response.

Runbooks decay silently; test them like code

A runbook script that references an old service name, a deprecated metrics query, or a since-removed feature flag will fail exactly when it's needed most — during an actual incident, under pressure, with no time to debug the runbook itself. Running runbook scripts periodically against a staging environment, or including them in game-day exercises, catches this drift before a real incident does. A runbook that hasn't been exercised in six months should be treated with the same suspicion as a backup that's never been restored.

Don't automate a step you don't fully understand yet

If the reason a manual step works is "we're not entirely sure why, but doing X usually fixes it," automating X without understanding the underlying mechanism just makes the mystery execute faster and with less human judgment applied at the moment it runs. Understand the failure mode first; automate the fix once it's genuinely well understood.

Wrapping up

Runbook automation pays off in a clear order: diagnosis first (zero risk, immediate time savings), human-triggered remediation second (removes typo and syntax risk, keeps judgment in the loop), and full auto-remediation last, reserved narrowly for failure modes well-understood enough that a human's judgment genuinely isn't adding value. Test runbooks like code, because a runbook that only gets exercised during real incidents will have silently rotted the one time it matters.

John Kihiu
Acumatica ERP Developer · Laravel Engineer

Independent software engineer in Nairobi specialising in Acumatica customisations, Laravel backends, and tax fiscalisation integrations across East and Southern Africa.