Write incident runbook

From pjt222/agent-almanac · View interactive version

Write incident runbook is an AI agent skill from the GitHub repository pjt222/agent-almanac. Create structured incident runbooks with diagnostic steps, resolution procedures, escalation paths, and communication templates for effective incident response. Use when documenting response procedures for recurring alerts, standardizing incident response across an on-call rotation, reducing MTTR wi

How to use this skill

Skill file

Write Incident Runbook

Create actionable runbooks that guide responders through incident diagnosis and resolution.

When to Use

Inputs

Procedure

Step 1: Choose Runbook Template Structure

See Extended Examples for complete template files.

Select an appropriate template based on incident type and complexity.

Basic runbook template structure:

# [Alert/Incident Name] Runbook
## Overview | Severity | Symptoms
## Diagnostic Steps | Resolution Steps
## Escalation | Communication | Prevention | Related

Advanced SRE runbook template (excerpt):

# [Service Name] - [Incident Type] Runbook

## Metadata
- Service, Owner, Severity, On-Call, Last Updated

## Diagnostic Phase
### Quick Health Check (< 5 min): Dashboard, error rate, deployments
### Detailed Investigation (5-20 min): Metrics, logs, traces, failure patterns
# ... (see EXAMPLES.md for complete template)

Key template components:

Got: Template selected matches incident complexity, sections appropriate for service type.

If fail:

Step 2: Document Diagnostic Procedures

See Extended Examples for complete diagnostic queries and decision trees.

Create step-by-step investigation procedures with specific queries.

Six-step diagnostic checklist:

  1. Verify Service Health: Health endpoint checks and uptime metrics

```bash

curl -I https://api.example.com/health # Expected: HTTP 200 OK

```

```promql

up{job="api-service"} # Expected: 1 for all instances

```

  1. Check Error Rate: Current error percentage and breakdown by endpoint

```promql

sum(rate(http_requests_total{status=~"5.."}[5m]))

/ sum(rate(http_requests_total[5m])) * 100 # Expected: < 1%

```

  1. Analyze Logs: Recent errors and top error messages from Loki

```logql

{job="api-service"} |= "error" | json | level="error"

```

  1. Check Resource Utilization: CPU, memory, and connection pool status

```promql

avg(rate(container_cpu_usage_seconds_total{pod=~"api-service."}[5m])) 100

# Expected: < 70%

```

  1. Review Recent Changes: Deployments, git commits, infrastructure changes
  1. Examine Dependencies: Downstream service health, database/API latency

Failure pattern decision tree (excerpt):

Got: Diagnostic procedures are specific, include expected vs actual values, guide responder through investigation.

If fail:

Step 3: Define Resolution Procedures

See Extended Examples for all 5 resolution options with full commands and rollback procedures.

Document step-by-step remediation with rollback options.

Five resolution options (brief summary):

  1. Rollback Deployment (fastest): For post-deployment errors

```bash

kubectl rollout undo deployment/api-service

```

Verify → Monitor → Confirm resolution (error rate < 1%, latency normal, no alerts)

  1. Scale Up Resources: For high CPU/memory, connection pool exhaustion

```bash

kubectl scale deployment/api-service --replicas=$((current * 3/2))

```

  1. Restart Service: For memory leaks, stuck connections, cache corruption

```bash

kubectl rollout restart deployment/api-service

```

  1. Feature Flag / Circuit Breaker: For specific feature errors or external dependency failures

```bash

kubectl set env deployment/api-service FEATURE_NAME=false

```

  1. Database Remediation: For database connections, slow queries, pool exhaustion

```sql

-- Kill long-running queries, restart connection pool, increase pool size

```

Universal verification checklist:

Rollback procedure: If resolution worsens situation → pause/cancel → revert → reassess

Got: Resolution steps are clear, include verification checks, provide rollback options for each action.

If fail:

Step 4: Establish Escalation Paths

See Extended Examples for full escalation levels and contact directory template.

Define when and how to escalate incidents.

When to escalate immediately:

Five escalation levels:

  1. Primary On-Call (5 min response): Deploy fixes, rollback, scale (up to 30 min solo)
  2. Secondary On-Call (auto after 15 min): Additional investigation support
  3. Team Lead (architectural decisions): Database changes, vendor escalation, incidents > 1 hour
  4. Incident Commander (cross-team coord): Multiple teams, customer comms, incidents > 2 hours
  5. Executive (C-level): Major impact (>50% users), SLA breach, media/PR, outages > 4 hours

Escalation process:

  1. Notify target with: current status, impact, actions taken, help needed, dashboard link
  2. Handoff if needed: share timeline, actions, access, remain available
  3. Don't go silent: update every 15 min, ask questions, provide feedback

Contact directory: Maintain table with role, Slack, phone, PagerDuty for:

Got: Clear criteria for escalation, contact information readily accessible, escalation paths aligned with organizational structure.

If fail:

Step 5: Create Communication Templates

See Extended Examples for all internal and external templates with full formatting.

Provide pre-written messages for incident updates.

Internal templates (Slack #incident-response):

  1. Initial Declaration:

```text

🚨 INCIDENT: [Title] | Severity: [Critical/High/Medium]

Impact: [users/services] | Owner: @username | Dashboard: [link]

Quick Summary: [1-2 sentences] | Next update: 15 min

```

  1. Progress Update (every 15-30 min):

```text

📊 UPDATE #N | Status: [Investigating/Mitigating/Monitoring]

Actions: [what we tried and outcomes]

Theory: [what we think is happening]

Next: [planned actions]

```

  1. Mitigation Complete:

```text

✅ MITIGATION | Metrics: Error [before→after], Latency [before→after]

Root Cause: [brief or "investigating"] | Monitoring 30min before resolved

```

  1. Resolution:

```text

🎉 RESOLVED | Duration: [time] | Root Cause + Impact + Follow-up actions

```

  1. False Alarm: No impact, no follow-up needed

External templates (status page):

Customer email template: Timeline, impact description, resolution, prevention, compensation (if applicable)

Got: Templates save time during incidents, ensure consistent communication, reduce cognitive load on responders.

If fail:

Step 6: Link Runbook to Monitoring

See Extended Examples for complete Prometheus alert configuration and Grafana dashboard JSON.

Integrate runbook with alerts and dashboards.

Add runbook links to Prometheus alerts:

- alert: HighErrorRate
  annotations:
    runbook_url: "https://wiki.example.com/runbooks/high-error-rate"
    dashboard_url: "https://grafana.example.com/d/service-overview"
    incident_channel: "#incident-platform"

Embed quick diagnostic links in runbook:

Create Grafana dashboard panel with runbook links (markdown panel listing all incident runbooks with on-call and escalation info)

Got: Responders can access runbooks directly from alerts or dashboards, diagnostic queries pre-filled, one-click access to relevant tools.

If fail:

Validation

Pitfalls

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.