Skip to content
advanced Phase 107 · Root Cause Analysis

Timeline Analysis

45m
1 problems
Topic Progress 0%

Timeline Analysis Overview

What is Timeline Analysis?

Timeline Analysis reconstructs the sequence of events:

1. Identify start of incident
2. Map all events in chronological order
3. Correlate events across systems
4. Identify trigger and contributing factors
5. Understand cascading effects

Benefits:
├── Clear picture of what happened
├── Identify trigger point
├── Understand cascading effects
├── Find correlation between events
└── Prevent future incidents

Timeline Components

Timeline Elements:
├── Time (timestamp)
├── Event (what happened)
├── Source (where it happened)
├── Impact (what was affected)
├── Action (what was done)
└── Result (what was the outcome)

Example Timeline

14:00:00 - Deployment started
14:05:00 - Code deployed to production
14:10:00 - Cache cleared
14:15:00 - Errors start appearing
14:20:00 - Monitoring alerts triggered
14:25:00 - Team notified
14:30:00 - Investigation started
14:35:00 - Root cause identified
14:40:00 - Rollback initiated
14:45:00 - Rollback completed
14:50:00 - System verified
14:55:00 - Incident resolved

Event Reconstruction

Gather Timeline Data

// Collect events from multiple sources
class TimelineCollector
{
    public function collectEvents($startTime, $endTime)
    {
        $events = [];
        
        // Application logs
        $events = array_merge($events, $this->getAppLogs($startTime, $endTime));
        
        // Database logs
        $events = array_merge($events, $this->getDbLogs($startTime, $endTime));
        
        // Server logs
        $events = array_merge($events, $this->getServerLogs($startTime, $endTime));
        
        // Monitoring alerts
        $events = array_merge($events, $this->getAlerts($startTime, $endTime));
        
        // Deployment records
        $events = array_merge($events, $this->getDeployments($startTime, $endTime));
        
        // Sort by timestamp
        usort($events, function($a, $b) {
            return $a['timestamp'] - $b['timestamp'];
        });
        
        return $events;
    }
}

Map Event Sequence

// Create event sequence
class EventSequencer
{
    public function sequence($events)
    {
        $sequence = [];
        $previousEvent = null;
        
        foreach ($events as $event) {
            $sequenceEvent = [
                'timestamp' => $event['timestamp'],
                'event' => $event['description'],
                'source' => $event['source'],
                'impact' => $this->determineImpact($event),
                'causality' => $previousEvent ? $this->determineCausality($previousEvent, $event) : null
            ];
            
            $sequence[] = $sequenceEvent;
            $previousEvent = $event;
        }
        
        return $sequence;
    }
    
    private function determineCausality($prev, $current)
    {
        // Determine if events are causally related
        if ($prev['source'] === $current['source']) {
            return 'same_source';
        }
        
        if (abs($prev['timestamp'] - $current['timestamp']) < 60) {
            return 'temporal';
        }
        
        return 'unrelated';
    }
}

Cross-System Correlation

Correlate Events Across Systems

// Correlation engine
class EventCorrelator
{
    public function correlate($events)
    {
        $correlated = [];
        
        foreach ($events as $event) {
            $key = $this->generateCorrelationKey($event);
            
            if (!isset($correlated[$key])) {
                $correlated[$key] = [];
            }
            
            $correlated[$key][] = $event;
        }
        
        return $correlated;
    }
    
    private function generateCorrelationKey($event)
    {
        // Use request ID, user ID, or order ID
        if (isset($event['request_id'])) {
            return 'request_' . $event['request_id'];
        }
        
        if (isset($event['order_id'])) {
            return 'order_' . $event['order_id'];
        }
        
        if (isset($event['user_id'])) {
            return 'user_' . $event['user_id'];
        }
        
        return 'time_' . floor($event['timestamp'] / 60);
    }
}

Correlation Examples

Correlation by Request ID:
├── 14:15:00 - Request ABC123 received
├── 14:15:01 - Request ABC123 - MySQL query
├── 14:15:02 - Request ABC123 - Redis cache miss
├── 14:15:03 - Request ABC123 - Payment gateway call
└── 14:15:04 - Request ABC123 - Response sent

Correlation by Order ID:
├── 14:20:00 - Order 456 created
├── 14:20:01 - Order 456 - Payment processed
├── 14:20:02 - Order 456 - Inventory reserved
├── 14:20:03 - Order 456 - Email sent
└── 14:20:04 - Order 456 - Status updated

Correlation by Time Window:
├── 14:15:00-14:16:00 - Multiple errors
├── 14:15:00 - MySQL connection error
├── 14:15:01 - Redis timeout
├── 14:15:02 - Payment gateway error
└── 14:15:03 - Application crash

Identify Patterns

// Pattern detection
class PatternDetector
{
    public function detect($events)
    {
        $patterns = [];
        
        // Detect error spikes
        $errorSpike = $this->detectErrorSpike($events);
        if ($errorSpike) {
            $patterns[] = $errorSpike;
        }
        
        // Detect performance degradation
        $perfDegradation = $this->detectPerfDegradation($events);
        if ($perfDegradation) {
            $patterns[] = $perfDegradation;
        }
        
        // Detect cascading failures
        $cascading = $this->detectCascadingFailures($events);
        if ($cascading) {
            $patterns[] = $cascading;
        }
        
        return $patterns;
    }
}

Timeline Documentation

Create Timeline Visualization

# Incident Timeline: INC-1234

## Date: 2025-01-15
## Duration: 14:00 - 14:55 (55 minutes)
## Impact: 20% checkout failures

## Timeline

| Time | Event | Source | Impact |
|------|-------|--------|--------|
| 14:00 | Deployment started | Git | None |
| 14:05 | Code deployed | Deploy | None |
| 14:10 | Cache cleared | Redis | Performance |
| 14:15 | Errors start | App | Users |
| 14:20 | Alerts triggered | Monitoring | Team |
| 14:25 | Team notified | PagerDuty | Response |
| 14:30 | Investigation started | Team | Resolution |
| 14:35 | Root cause found | Analysis | Fix |
| 14:40 | Rollback initiated | Deploy | Fix |
| 14:45 | Rollback completed | Deploy | Resolution |
| 14:50 | System verified | Testing | Confirmation |
| 14:55 | Incident resolved | Team | None |

## Key Events

### Trigger
- 14:05: Code deployment

### Contributing Factors
- 14:10: Cache cleared (removed warm cache)
- 14:15: New code had performance issue

### Resolution
- 14:40: Rollback to previous version

## Lessons Learned
1. Need better pre-deployment testing
2. Cache clearing caused cold start
3. Monitoring detected issue quickly

Document Findings

// Timeline analysis document
class TimelineDocument
{
    public function create($timeline, $correlations, $patterns)
    {
        return [
            'summary' => $this->createSummary($timeline),
            'timeline' => $timeline,
            'correlations' => $correlations,
            'patterns' => $patterns,
            'trigger' => $this->identifyTrigger($timeline),
            'contributing_factors' => $this->identifyContributingFactors($timeline),
            'resolution' => $this->identifyResolution($timeline),
            'lessons_learned' => $this->extractLessons($timeline, $patterns)
        ];
    }
}

Practice Problems

0 / 1 solved
Timeline Analysis Exercise

Create timeline for checkout failure incident from 14:00 to 14:55.

Solution
// Timeline:
// 14:00 - Deployment started
// 14:05 - Code deployed
// 14:10 - Cache cleared
// 14:15 - Errors start
// 14:20 - Alerts triggered
// 14:25 - Team notified
// 14:30 - Investigation started
// 14:35 - Root cause found
// 14:40 - Rollback initiated
// 14:45 - Rollback completed
// 14:50 - System verified
// 14:55 - Incident resolved

Quiz

1. What is timeline analysis?

Question 1 options

2. What is event correlation?

Question 2 options

3. What is the purpose of timeline documentation?

Question 3 options

4. What should a timeline include?

Question 4 options

Flashcards

Question

Timeline analysis purpose?

Answer

Reconstruct event sequence during incident

Question

Event correlation?

Answer

Link events using request/order/user IDs

Question

Timeline components?

Answer

Time, Event, Source, Impact, Action, Result

Question

Timeline documentation goal?

Answer

Understand incident, prevent recurrence

Question

Key timeline elements?

Answer

Trigger, contributing factors, resolution, lessons

Revision Notes

Key Takeaways

  • 1. Timeline: Reconstruct event sequence
  • 2. Correlation: Link events across systems
  • 3. Components: Time, Event, Source, Impact, Action
  • 4. Documentation: Trigger, factors, resolution, lessons
  • 5. Goal: Understand incident, prevent recurrence

Interview Tips

  • Explain timeline analysis process
  • Discuss correlation techniques
  • Know documentation best practices
  • Understand pattern detection

Cheat Sheet

Timeline Analysis

  • Purpose: Reconstruct event sequence
  • Correlation: Link by request/order/user ID
  • Components: Time, Event, Source, Impact, Action
  • Document: Trigger, factors, resolution, lessons
  • Goal: Understand, prevent recurrence