AI for IT Certification
Aware · M32 · lesson 32 of 120 · queued
Preview — browse every lesson free. Enroll to mark lessons complete, open partner links and save your progress. Login & enroll →
Automated Root Cause Analysis
📖
now learning

Automated Root Cause Analysis

15 min

Overview

An incident fires at 2 AM. Your on-call engineer wakes up and starts investigating. They spend 30 minutes reading logs, checking metrics, correlating changes. Then they find the root cause: a deployment 20 minutes ago introduced a memory leak. They could have known this in 2 minutes if an AI system had already done the correlation work.

This lesson teaches you to automate the investigation phase of incident response. Not to replace human judgment, but to narrow the search space so humans can confirm or refute a hypothesis in minutes instead of hours.

Purpose

Root cause analysis (RCA) is the most time-consuming phase of incident response. You have an error rate spike. Is it a deployment? A configuration change? A dependency issue? A traffic spike? You start with a dozen hypotheses and have to narrow it down through investigation.

An AI system can do this narrowing automatically. It can:

  • Correlate the timing of the incident with recent changes
  • Map service dependencies and identify which ones changed
  • Pull relevant logs and metrics
  • Generate ranked hypotheses from strongest to weakest
  • Suggest verification steps to confirm or refute each hypothesis

The engineer still makes the final call ("Yes, this is the root cause"), but they do it with full context instead of starting from scratch.

Why This Matters

A major outage at an e-commerce company caused 6 hours of downtime. The root cause was a single database configuration change made 2 hours before the outage. A DBA applied it without thinking about the implications.

The investigation took 3 hours because:

  • Database performance was degraded, but logs didn't show obvious errors
  • It took 90 minutes to find the recent configuration change
  • It took another 90 minutes to understand why that specific change broke things
  • By the time they understood, they'd already wasted investigative effort on wrong hypotheses

If they'd had automated RCA:

  • AI would correlate the incident (database latency spike) with the configuration change (happened 2 hours before, exact same time)
  • AI would rank this as the strongest hypothesis (95% confidence)
  • Engineers would see: "Database configuration change likely cause. Recent change X differs from baseline."
  • Investigation time: 30 minutes (instead of 3 hours)
  • Downtime: 30 minutes (instead of 6 hours)
  • Cost: $50k (instead of $300k)

Core Concepts

Key insight: RCA is a hypothesis ranking problem

Root causes rarely jump out. You have multiple candidate explanations:

  1. Recent deployment caused issue (60% confidence)
  2. Dependency service had problem (40% confidence)
  3. Database query performance degraded (35% confidence)
  4. Configuration change broke something (25% confidence)
  5. Network issue (15% confidence)

Your job is to:

  • Rank hypotheses by likelihood
  • Collect evidence for each
  • Eliminate improbable hypotheses
  • Verify the top hypothesis
  • Confirm root cause

Automated RCA speeds up steps 1-4. Humans own step 5-6 (verification and confirmation).

Key insight: Data gathering is 70% of the work

To rank hypotheses, you need:

  • Change data: What was deployed, when? What configuration changed, when? What infrastructure changed?
  • Metric data: How did CPU, memory, latency, error rate change over the incident timeline?
  • Log data: What errors appeared in logs? What's the sequence?
  • Dependency data: Which services depend on the affected service? Did they also fail?
  • Historical data: Have we seen similar incidents? What was the root cause then?

Gathering this manually takes 30 minutes. AI can gather it in 30 seconds by querying your systems.

Example: Manual vs. Automated Data Gathering

Manual:

  1. Open monitoring dashboard (1 min)
    2. Pull metrics for the affected service (3 min)
    3. Check deployment history (5 min)
    4. Search logs for errors (10 min)
    5. Check if dependency services were affected (5 min)
    6. Ask team "Did anything change?" (5 min)
    7. Total: 29 minutes

Automated:

  1. Query all metric sources in parallel
    2. Pull deployment history from CI/CD system
    3. Search logs for "error" + "exception" + "failed"
    4. Map affected service to dependencies
    5. Cross-reference with change log
    6. Correlate timing of all events
    Total: 30 seconds

Key insight: Correlation logic identifies patterns

Once you have the data, you look for patterns:

Pattern 1: Temporal correlation

  • Incident started at 2:15 AM
  • Deployment happened at 2:10 AM
  • Correlation: 95% (very unlikely to be coincidence)

Pattern 2: Service dependency correlation

  • Service-A (which just deployed) depends on Database
  • Service-B (which depends on Service-A) also showed errors
  • Correlation: If Service-A fails, Service-B fails (dependency implies causation)

Pattern 3: Metric correlation

  • Deployment at 2:10 AM
  • Memory usage spiked at 2:11 AM (1 minute later)
  • Error rate spiked at 2:13 AM (3 minutes later)
  • Correlation: Deployment → Memory spike → Error spike (causal chain)

Pattern 4: Historical correlation

  • We've had 15 incidents in past year
  • 14 of them had similar error signature to today's incident
  • 12 of those 14 were caused by "memory leak in service-X"
  • Correlation: 85% confidence this is same root cause as before

Key insight: Hypothesis generation is automated, hypothesis verification is human

Once you've ranked hypotheses, you move to verification. But you don't verify all hypotheses equally.

Hypothesis verification workflow:

Ranked hypotheses:
1. Recent deployment caused memory leak (95% confidence)
2. Database query timeout (45% confidence)
3. Traffic spike hit capacity limit (30% confidence)

Verification step 1: Check hypothesis 1 (95% confidence)
Suggested check: "Did memory usage spike after deployment?"
Engineer checks: Yes, memory spiked from 45% to 85% right after deployment.
Confidence increases: 95% → 98%

Next check: "Did error logs mention OutOfMemoryError?"
Engineer checks: Yes, logs show "java.lang.OutOfMemoryError: heap space"
Confidence increases: 98% → 99%

Verification complete: Hypothesis 1 confirmed.

Hypothesis 2 and 3 eliminated (no need to check if 1 is confirmed).

The engineer spends 5 minutes verifying the top hypothesis instead of 30 minutes investigating all three.

Key insight: Runbook suggestions make remediation obvious

Once the root cause is confirmed, what do you do?

For known root causes, AI can suggest remediation from your runbooks:

Root cause confirmed: "Deployment service-x-v2.1 caused memory leak"

AI suggests:
1. Check known fixes in runbook for "service-x memory leak"
2. Historical fix: Downgrade to service-x-v2.0 (worked 3 times before)
3. Alternative fix: Increase heap size from 2GB to 4GB (temporary workaround)
4. Best practice: Rollback to v2.0 (safer, faster)

Engineer decides: "Rollback to v2.0"
AI executes: Initiates rollback, monitors metrics

You've reduced decision time from "What do I do?" (15 minutes of thinking) to "Here's what worked before, is this acceptable?" (2 minutes of confirmation).

Key insight: Feedback loops improve RCA over time

After each incident, capture:

  • What was the root cause?
  • What did the AI hypothesis ranking predict?
  • How well did it perform?

Incident: Database query timeout
AI prediction: Deployment caused issue (95% confidence)
Actual cause: Database statistics outdated, causing bad query plan
AI was wrong

Analysis: AI overweighted "deployment" because one happened 30 min before.
AI underweighted "database statistics" because stats aren't in change log.
Solution: Add database statistics to change tracking.
Next time: AI will see stats change and rank it higher.

Learning: If database stats changed + query latency degraded = strong hypothesis

Practical Use Cases

Use Case 1: End-to-End RCA for E-Commerce Checkout Outage

Incident: Checkout service returns 500 errors. Users can't complete purchases. Revenue dropping $2k per minute.

STEP 1: Symptom Collection (Automated)
Query monitoring system:
- Checkout service: Error rate 95% (normally <0.1%)
- Checkout service: Latency p95 5000ms (normally 200ms)
- Payment gateway: No errors reported
- Database: Query latency normal
- Cache: Normal hit rates, no evictions
- API gateway: Normal traffic (no unusual spike)

STEP 2: Data Gathering (Automated, 30 seconds)
- Pull deployment history: checkout-v3.2.1 deployed 8 minutes ago
- Pull configuration changes: No recent changes
- Pull infrastructure changes: No scaling events
- Pull dependent service changes: payment-gateway deployed 1 hour ago (but working fine)
- Pull error logs: Checkout throwing "NullPointerException in PaymentProcessor"
- Historical incidents: 3 similar incidents all from "dependency API version mismatch"

STEP 3: Correlation & Hypothesis Generation (Automated)

Correlations found:
- Checkout deployment 8 min ago
- Error started 8 min ago (perfect correlation)
- Error type: NullPointerException in PaymentProcessor
- Payment service version: Still old version (not updated with checkout)

Ranked hypotheses:
1. Checkout v3.2.1 has new API that payment-gateway v3.1.0 doesn't support
Confidence: 92%
Evidence: Deployment timing, error in PaymentProcessor, version mismatch
Historical: 3 similar incidents, all from API mismatch

  1. Checkout v3.2.1 has memory leak that causes OOM
    Confidence: 15%
    Evidence: None (memory normal, no OutOfMemoryError in logs)
    Eliminated: No supporting evidence
  2. Database connection pool exhaustion
    Confidence: 5%
    Evidence: None (database latency normal, connections not maxed)
    Eliminated: No supporting evidence

STEP 4: Suggested Verification Steps (Automated)
To verify hypothesis 1:
1. Check checkout error logs for mentions of "payment" or "version"
Result: Error log says "PaymentProcessor expects version 3.2, got 3.1"
Confirmation: 92% → 97%

  1. Compare checkout v3.2.1 release notes with payment-gateway v3.1 compatibility
    Result: Release notes say "requires payment-gateway v3.2 or higher"
    Confirmation: 97% → 99%

STEP 5: Suggested Remediation (Automated)
Root cause confirmed: API version mismatch

Options ranked by speed + safety:
1. Upgrade payment-gateway to v3.2.1 (2 min execution, full fix)
2. Downgrade checkout to v3.1.0 (1 min execution, but loses new features)
3. Patch checkout to support both v3.1 and v3.2 (30 min, best long-term)

Recommendation: Option 1 (upgrade payment-gateway)

STEP 6: Engineer Review & Approval
Engineer sees summary:
"Checkout deployment v3.2.1 incompatible with payment-gateway v3.1.0.
Suggested fix: Upgrade payment-gateway to v3.2.1.
Estimated MTTR: 5 minutes (deployment + verification)"

Engineer: "Approved. Proceed with payment-gateway upgrade."

STEP 7: Execution & Verification (Automated)
AI executes:
1. Upgrade payment-gateway to v3.2.1
2. Run integration tests (2 min)
3. Monitor error rate (drops from 95% to <0.1% within 30 sec)
4. Verify checkout can complete (test transaction succeeds)

Result: MTTR 5 minutes
Revenue impact: $10k lost (5 minutes × $2k/min) instead of $60k (30 minutes with manual investigation)

STEP 8: PIR & Feedback Loop
Root cause: API version mismatch
Why didn't we catch it? No pre-deployment compatibility check between services
Action item: Add compatibility check in CI/CD (if checkout changes API, verify all dependents can handle it)

Feedback to AI:
- API version mismatches → Very strong hypothesis (100% confidence next time)
- Checkout + payment service together → Strong dependency correlation
- Error message "expects version X, got Y" → Signature for version mismatch problems

Impact:

  • Manual investigation: 30 minutes (read logs, check deployments, ask team, figure out compatibility)
  • Automated RCA: 5 minutes (AI gathers data, ranks hypotheses, suggests fix, engineer approves)
  • 6x faster response
  • $50k in saved revenue

Use Case 2: RCA for Intermittent Database Performance Issue

Incident: Database query latency spiking randomly. Sometimes 200ms, sometimes 1000ms. Doesn't correlate with traffic.

Manual investigation approach:

  1. Check database metrics (5 min)
    - CPU: 60% average, sometimes spikes to 90%
    - Memory: Normal
    - Disk I/O: High
    - Query queue: 50 queries waiting
  2. Check recent changes (10 min)
    - No recent deployments
    - No recent configuration changes
    - No recent schema changes
  3. Ask team (5 min)
    - "Did anyone change anything?" No.
    - "Any known issues?" No.
  4. Dig into logs (30 min)
    - Find slow queries in logs
    - One query: "SELECT * FROM large_table WHERE condition" takes 2 seconds
    - This query is being called 1000 times per second
    - Query execution plan: Full table scan (inefficient)
  5. Check if something changed with that query (10 min)
    - Code history: No recent changes
    - Database schema: No recent changes to large_table
  6. Investigation dead-end: What caused the query to become slow suddenly?
    - Database statistics outdated? (Check stats) Stats are from 1 hour ago, should be fine
    - Missing index? (Check indexes) No obvious missing index
    - Intermittent issue (maybe disk I/O contention?)
  7. Give up investigation, apply known fix (5 min)
    - "Let's rebuild the statistics"
    - Run ANALYZE on large_table
    - Problem goes away... for now

Total time: 60 minutes
Root cause: Unknown (just got lucky with the stats rebuild)

Automated RCA approach:

Step 1: Symptom analysis (automated)
- Query latency: Intermittent spikes to 1000ms
- Correlated with: High disk I/O
- Correlated with: CPU spikes
- Not correlated with: Traffic volume

Step 2: Data gathering (automated, 30 sec)
- Pull slow query logs: "SELECT * FROM large_table WHERE condition" is slow
- Check query execution plan: Full table scan (no index)
- Check if index exists: Index exists (idx_condition) but not being used
- Check table statistics: Last updated 1 hour ago
- Check disk I/O: High, correlates with query spikes
- Pull system events: Backup job running 00:00-02:00 daily
- Check incident history: Similar incidents 5 times in past month, always around midnight

Step 3: Hypothesis ranking (automated)
1. Query execution plan using wrong index (not using idx_condition)
Confidence: 85%
Evidence: Index exists, but execution plan shows full table scan
Cause: Statistics outdated, optimizer chose wrong plan

  1. Intermittent disk I/O contention (backup job)
    Confidence: 80%
    Evidence: High disk I/O correlates with query latency
    Incidents 5x in past month, all around backup time
    Cause: Backup competes with query for disk
  2. Network contention or replication lag
    Confidence: 10%
    Evidence: None
    Eliminated

Step 4: Verification steps (automated)
1. When did query execution plan change?
Result: Never changed. Plan has been full table scan for 3 months.

  1. Why is query suddenly slow now?
    Answer: Statistics are outdated. Optimizer no longer trusts statistics, reverts to conservative full scan.
    When were stats last updated?
    Result: 1 hour ago, but that's from scheduled job. Job failing to run properly?
    Check stats recency: Stats should be updated every 4 hours. Last update was 48 hours ago!
    Confirmation: 95%
  2. Correlation: Incidents happen at midnight when backup runs
    Result: Yes, 5/5 recent incidents happened during backup window
    Confirmation: 98%

Step 5: Root cause confirmed
Two factors:
1. Database statistics are stale (48 hours old instead of 4 hours)
2. Backup job is causing disk I/O contention

Combined: Stale stats cause optimizer to choose inefficient plan.
Disk I/O contention makes inefficient plan even slower.

Why did stats get stale? Statistics job is failing silently.

Step 6: Remediation options
1. Fix statistics job (long-term fix, 1-2 hours to test and deploy)
2. Rebuild statistics manually (immediate fix, 5 minutes, but only temporary)
3. Change query to use index hint (quick workaround, 15 minutes, might miss future optimizations)
4. Reschedule backup to off-peak (requires coordination, 1 hour)

Recommended: Option 2 (temporary) + Option 1 (permanent)

Step 7: Execution
Immediate: Rebuild statistics (5 min) → Latency returns to normal
Long-term: Fix statistics job + add monitoring (deploy next day)

Total time: 5 minutes (immediate fix) instead of 60 minutes (manual investigation)
Root cause: Properly identified (stale stats + disk I/O contention), not just guessed

Impact:

  • Before: 60 minutes investigation, guessed at fix, didn't address root cause
  • After: 5 minutes investigation, proper root cause identified, fixes deployed
  • 12x faster response
  • Permanent fix deployed within 24 hours (instead of never addressing the real issue)

Anti-Patterns

Anti-Pattern 1: "AI just guesses at root cause"

You deploy an RCA system that looks at an incident and outputs "probably a memory leak" without any supporting evidence. Engineers learn that AI is unreliable and stop trusting it.

Why it fails: Unsupported hypotheses erode trust. Engineers need to see evidence: "Here's why I think memory leak: (1) Memory spiked right after deployment, (2) Error logs mention OutOfMemory."

How to avoid it: Every hypothesis should come with ranked evidence. Show data. Make the reasoning transparent. If confidence is low (<60%), label it as "uncertain, check manually." Let humans verify, not just guess.

Anti-Pattern 2: "We didn't instrument the change log"

Your RCA system can't identify recent deployments, configuration changes, or infrastructure changes. Because nobody logs these in a structured way.

Deployments might be logged in a Slack channel. Configuration changes might be documented in a wiki. Infrastructure changes might just be verbal ("I added two more servers yesterday").

Without structured change data, AI can't correlate changes with incidents.

Why it fails: Garbage in, garbage out. If you don't have the data AI needs, AI can't help.

How to avoid it: Instrument change logging. Integrate your CI/CD, configuration management, and infrastructure tools so AI can query what changed and when. This is a prerequisite to automated RCA.

Anti-Pattern 3: "RCA automation is the same as incident resolution"

You deploy an automated RCA system that identifies the root cause and *automatically executes* a fix. No human involved.

But sometimes the AI's fix makes things worse. Or the root cause was correct but the fix was wrong for your specific context.

Why it fails: RCA is the investigation phase. Resolution is the execution phase. You need humans to verify the diagnosis and approve the fix, even if finding the diagnosis is automated.

How to avoid it: Automate RCA (investigation + hypothesis ranking). Keep resolution (fix execution) as human-approved. Let AI suggest a fix and the steps to verify it, but have humans click "Approve" before execution.

Anti-Pattern 4: "Feedback loops are optional"

You deploy RCA and it works okay. But you don't capture what it predicted vs. what the actual root cause was.

Six months later, your systems have changed. Your dependencies changed. Your common failure modes changed. But the RCA system doesn't know this. It keeps suggesting hypotheses that were relevant 6 months ago, not today.

Why it fails: Without feedback, the system can't improve. Without measuring accuracy, you don't know if it's degrading.

How to avoid it: After every incident, log the actual root cause and what AI predicted. Review monthly. Adjust weighting and patterns based on what you learn. Make RCA systems continuous learners.

Anti-Pattern 5: "We only automated for known root causes"

You hardcode rules: "If deployment happened 30 minutes before incident, it's probably the cause." This works for obvious cases (deployment → immediate error). But it fails for subtle interactions.

A deployment 8 hours before an incident might cause a memory leak that manifests 8 hours later. Your rules miss this because the temporal correlation is weak.

Why it fails: Hand-coded rules don't scale to all possible root causes. You miss patterns you didn't anticipate.

How to avoid it: Use data-driven pattern learning, not hand-coded rules. Let the system learn from historical incidents. If past incidents showed that "memory leak manifests 8 hours post-deployment," the system learns this pattern and applies it.

Human Judgment Checkpoints


  • Hypothesis confidence: Are hypotheses ranked with confidence scores? Low-confidence hypotheses should be labeled as uncertain.

  • Evidence transparency: Can you see the evidence supporting each hypothesis? Or is it a black box?

  • Verification suggestions: Does the system suggest how to verify the top hypothesis? Or does the engineer have to figure it out?

  • Data integration: Can the system query your deployment logs, change logs, and configuration management? Or is change data siloed?

  • Feedback capture: Are you logging AI predictions vs. actual root causes? Can you measure accuracy?

Key Takeaways

RCA is hypothesis ranking, not just data analysis. Multiple possible root causes exist. AI ranks them by likelihood. Humans verify the top hypothesis. This is faster than starting from scratch.

Automate data gathering. Pulling logs, metrics, deployments, and changes manually takes 30 minutes. Automating this takes 30 seconds. The biggest time savings come from automated data collection.

Correlation patterns eliminate investigation time. Deployment 10 minutes before incident? Strong signal. Service-A failed, Service-B (dependent) also failed? Strong signal. Historical pattern matching? Strong signal. Use these to rank hypotheses.

Evidence matters more than confidence. A hypothesis with 80% confidence and strong evidence is more trustworthy than 95% confidence with no supporting data.

Humans verify, AI ranks. The engineer still makes the final call ("Yes, this is the root cause"). But AI narrows the search space so they verify in 5 minutes instead of investigating for 30 minutes.

Feedback loops are critical for improving RCA over time. After each incident, log what AI predicted and what the actual cause was. Use this to improve hypothesis ranking.

Runbook integration accelerates remediation. Once root cause is confirmed, AI suggests remediation from historical playbooks. Engineers don't have to figure out what to do; they review the suggestion and approve.