---
runspace: 1
title: Incident response runbook
collection: Templates
variables:
    - name: service
      default: api
    - name: environment
      default: production
---

# Incident response runbook

> The runbook for the first thirty minutes of an incident whose cause is not
> yet known: capture the signal, establish scope, test one hypothesis at a
> time, and make only reversible changes until the original signal clears.
>
> Replace the diagnostic commands with the ones for your stack; keep the
> order. Imports into Runspace as a runbook, where every fenced command is a
> step a person approves before it runs.

## 0. Before anything

- Say in the incident channel that you are on it, and which service.
- Note the time the symptom started, from the alert or the first report, not
  from when you noticed.
- Do not restart, roll back or scale anything yet. Evidence first.

## 1. Establish the facts

What is observed, exactly? Write it as a sentence a stranger could verify:
"checkout returns 502 for about 30% of requests since 14:07 UTC."

Confirm the scope before the cause. Which environment, which service, which
users, how many.

```sh {intent="diagnostic"}
# Replace with the health check for {{service}} in {{environment}}
curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' https://{{service}}.example.com/healthz
```

```sh {intent="diagnostic"}
# What changed recently? Deploys, config, feature flags, infrastructure.
# Replace with your deploy tool's history for {{service}}.
git log --since='6 hours ago' --format='%h %ad %s' --date=short
```

Check: the facts name one service, one environment, a start time and a blast
radius. If two services are failing, decide which is upstream before going
on.

## 2. Decide whether to roll back first

If something was deployed to {{service}} inside the window before the
symptom started, rolling it back is the fastest reversible change there is,
and it is safe to do before you understand the cause.

```sh {intent="change" timeout=600}
# Replace with your rollback command for {{service}}, e.g.
# kubectl -n {{environment}} rollout undo deploy/{{service}}
echo "rollback {{service}} in {{environment}}"
```

If nothing was deployed, skip this step and say so in the channel.

## 3. Test one hypothesis

Write the hypothesis in one line and the evidence that would disprove it.
Test the cheapest one first. Common first hypotheses, in the order they
usually pay off:

1. A dependency is failing (database, cache, a third-party API).
2. The service is out of a resource (connections, memory, file handles, disk).
3. A configuration or secret changed or expired.

```sh {intent="diagnostic"}
# Replace with a check of the dependency you suspect, e.g. a DB ping,
# a cache INFO, a third-party status endpoint.
echo "check dependency for {{service}}"
```

```sh {intent="diagnostic"}
# Replace with your resource check for {{service}}: connection pool,
# memory, open files, disk.
echo "check resources for {{service}}"
```

Record the result of each test, including the ones that cleared a
hypothesis. Negative results are what keep the next person from repeating
them.

## 4. Recover

Make the smallest reversible change that addresses the confirmed hypothesis.
One change at a time, with a pause to observe after each. Write down what
you changed and when.

```sh {intent="change" timeout=600}
# Replace with the recovery action for the confirmed cause.
echo "recover {{service}}"
```

## 5. Verify against the original signal

A finished command is not a recovery. Check the thing that was wrong in
step 1, not the thing you changed. Record what you checked and the time.

```sh {intent="diagnostic"}
curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' https://{{service}}.example.com/healthz
```

Say in the channel that the symptom has cleared, with the time, and keep
watching for ten minutes before calling it resolved.

## 6. Leave it better

- Open the postmortem while the timeline is fresh; this runbook's record is
  most of it.
- Which step here was wrong, vague or missing? Fix the runbook now.
- Which hypothesis was right? That is the next runbook to write, if it does
  not exist.
- What fix to the system would make this incident impossible?
