Postmortem Template in Java
/** * POST TITLE: Incident Postmortem Report Template * * This template provides a structured approach for documenting * incident postmortems in Java applications. */ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; public class PostmortemTemplate { // Basic incident information private String incidentTitle; private LocalDateTime startTime; private LocalDateTime endTime; private LocalDateTime postmortemDate; private String severity; private String affectedServices; // Incident details private String summary; private String impact; private String rootCause; private String trigger; private String detection; private String resolution; // Action items private List<ActionItem> actionItems; private List<String> lessonsLearned; // Team information private String incidentCommander; private List<String> responders; private List<String> stakeholders; public static class ActionItem { private String description; private String owner; private LocalDateTime dueDate; private String status; // TODO, IN_PROGRESS, COMPLETED private String priority; // HIGH, MEDIUM, LOW public ActionItem(String description, String owner, LocalDateTime dueDate, String priority) { this.description = description; this.owner = owner; this.dueDate = dueDate; this.priority = priority; this.status = "TODO"; } // Getters and setters public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getOwner() { return owner; } public void setOwner(String owner) { this.owner = owner; } public LocalDateTime getDueDate() { return dueDate; } public void setDueDate(LocalDateTime dueDate) { this.dueDate = dueDate; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getPriority() { return priority; } public void setPriority(String priority) { this.priority = priority; } @Override public String toString() { return String.format("Action: %s | Owner: %s | Due: %s | Priority: %s | Status: %s", description, owner, dueDate.toLocalDate(), priority, status); } } public PostmortemTemplate() { this.actionItems = new ArrayList<>(); this.lessonsLearned = new ArrayList<>(); this.responders = new ArrayList<>(); this.stakeholders = new ArrayList<>(); this.postmortemDate = LocalDateTime.now(); } // Core postmortem sections public void setIncidentDetails(String title, LocalDateTime start, LocalDateTime end, String severity) { this.incidentTitle = title; this.startTime = start; this.endTime = end; this.severity = severity; } public void setAnalysis(String summary, String impact, String rootCause, String trigger, String detection, String resolution) { this.summary = summary; this.impact = impact; this.rootCause = rootCause; this.trigger = trigger; this.detection = detection; this.resolution = resolution; } public void addActionItem(String description, String owner, LocalDateTime dueDate, String priority) { this.actionItems.add(new ActionItem(description, owner, dueDate, priority)); } public void addLessonLearned(String lesson) { this.lessonsLearned.add(lesson); } public void setTeam(String incidentCommander, List<String> responders, List<String> stakeholders) { this.incidentCommander = incidentCommander; this.responders = responders; this.stakeholders = stakeholders; } // Generate postmortem report public void generateReport() { System.out.println("=== INCIDENT POSTMORTEM REPORT ==="); System.out.println(); System.out.println("INCIDENT OVERVIEW"); System.out.println("Title: " + incidentTitle); System.out.println("Severity: " + severity); System.out.println("Start Time: " + startTime); System.out.println("End Time: " + endTime); System.out.println("Duration: " + calculateDuration()); System.out.println("Postmortem Date: " + postmortemDate.toLocalDate()); System.out.println(); System.out.println("TEAM"); System.out.println("Incident Commander: " + incidentCommander); System.out.println("Responders: " + String.join(", ", responders)); System.out.println("Stakeholders: " + String.join(", ", stakeholders)); System.out.println(); System.out.println("SUMMARY"); System.out.println(summary); System.out.println(); System.out.println("IMPACT"); System.out.println(impact); System.out.println(); System.out.println("TIMELINE & ANALYSIS"); System.out.println("Trigger: " + trigger); System.out.println("Detection: " + detection); System.out.println("Resolution: " + resolution); System.out.println("Root Cause: " + rootCause); System.out.println(); System.out.println("ACTION ITEMS"); for (int i = 0; i < actionItems.size(); i++) { System.out.println((i + 1) + ". " + actionItems.get(i)); } System.out.println(); System.out.println("LESSONS LEARNED"); for (int i = 0; i < lessonsLearned.size(); i++) { System.out.println((i + 1) + ". " + lessonsLearned.get(i)); } } private String calculateDuration() { if (startTime != null && endTime != null) { long minutes = java.time.Duration.between(startTime, endTime).toMinutes(); return minutes + " minutes"; } return "N/A"; } // Example usage public static void main(String[] args) { PostmortemTemplate postmortem = new PostmortemTemplate(); // Set incident details postmortem.setIncidentDetails( "Database Connection Pool Exhaustion", LocalDateTime.of(2024, 1, 15, 14, 30), LocalDateTime.of(2024, 1, 15, 16, 45), "SEV-2" ); // Set team information postmortem.setTeam( "Jane Smith", List.of("John Doe", "Bob Wilson", "Alice Johnson"), List.of("Product Team", "Customer Support", "Engineering Leadership") ); // Set analysis postmortem.setAnalysis( "Database connection pool was exhausted due to unclosed connections in the payment service", "Payment processing was down for 2 hours, affecting 15% of transactions", "Missing connection cleanup in error handling code path", "Traffic spike during flash sale event", "Monitoring alerts for high database connection count", "Restarted service with increased connection pool size and deployed hotfix" ); // Add action items postmortem.addActionItem( "Fix connection leak in payment service", "John Doe", LocalDateTime.of(2024, 1, 22, 23, 59), "HIGH" ); postmortem.addActionItem( "Add connection pool monitoring dashboard", "Alice Johnson", LocalDateTime.of(2024, 1, 30, 23, 59), "MEDIUM" ); // Add lessons learned postmortem.addLessonLearned("Need better error handling testing for database operations"); postmortem.addLessonLearned("Connection pool limits should be reviewed during capacity planning"); postmortem.addLessonLearned("Improve monitoring for connection pool metrics"); // Generate the report postmortem.generateReport(); } }

This Java postmortem template provides:

  1. Structured incident documentation with all essential sections
  2. Action item tracking with owners, due dates, and priorities
  3. Team collaboration tracking responders and stakeholders
  4. Automatic duration calculation for incident timeline
  5. Professional report generation in a standardized format

The template follows industry best practices for incident postmortems and can be easily extended or integrated with other systems.

Leave a Reply

Your email address will not be published. Required fields are marked *


Macro Nepal Helper