AI Incident Evidence Assistant: Correlated SRE Incident Investigation
Building an evidence-linked incident investigation platform that correlates sanitized logs, distributed traces, and deployment markers with operator-approved remediation runbooks.
Executive Summary
During high-severity production outages, Site Reliability Engineers face intense cognitive overload navigating fragmented dashboards, thousands of log lines, and distributed traces under tight MTTR pressure. The AI Incident Evidence Assistant unifies operational investigation by ingesting sanitized telemetry, correlating logs, traces, and deployment markers into evidence-linked incident timelines, generating scoped diagnostic probes, and proposing risk-classified remediation plans with mandatory rollback steps and human operator approval gates.
The Engineering Challenge & Context
Incident responders lose critical minutes manually cross-referencing timestamps between Grafana metrics, Datadog traces, Kubernetes deployment logs, and static Markdown runbooks. Generic LLMs queried during outages hallucinate non-existent service dependencies, recommend dangerous unverified commands, and lack access to the underlying evidence required for safe operational decision-making.
System Architecture & Data Flow
The system pairs a high-performance NestJS 11 backend service on Render with a responsive Next.js 14 SRE console on Vercel. Ingested operational logs and OpenTelemetry spans pass through an automated secret and PII redaction pipeline before correlation. A chronological timeline engine aligns metric anomaly markers with deployment events. The assistant generates evidence-linked hypotheses strictly separating observable facts from AI interpretations, produces safe read-only PromQL/LogQL queries, and enforces a mandatory human approval boundary before any remediation step can be executed.
+-----------------------------------------------------------------------------------+
| TELEMETRY INGESTION & REDACTION |
| Logs (Loki), Traces (OpenTelemetry), Metrics (Prometheus), CI/CD Events |
+-----------------------------------------------------------------------------------+
|
v
+-----------------------------------------------------------------------------------+
| AUTOMATED SECRET & PII SANITIZER |
| Redacts Bearer tokens, API keys, basic auth passwords, connection URIs, & PII |
+-----------------------------------------------------------------------------------+
|
v
+-----------------------------------------------------------------------------------+
| EVIDENCE CORRELATION ENGINE |
| |
| [ Unified Chronological Timeline ] |
| - Correlates error rate spikes with preceding CI/CD deployment markers |
| - Links trace latency bottlenecks directly to anomalous database slow queries |
| |
| [ Grounded Hypothesis Generator ] |
| - Strict Separation: Observable Facts vs. AI Interpretations |
| - Attaches exact log lines and trace IDs as verifiable evidence anchors |
+-----------------------------------------------------------------------------------+
|
v
+-----------------------------------------------------------------------------------+
| OPERATOR-IN-THE-LOOP REMEDIATION GATE |
| |
| 1. Synthesizes Scoped Diagnostic Queries (Read-Only PromQL / LogQL / kubectl) |
| 2. Formulates Risk-Classified Remediation Plan (P1-P4 Risk Assessment) |
| 3. Enforces Mandatory Rollback Procedures & Dry-Run Verification Steps |
| |
| +----------------------------+----------------------------+ |
| | Operator Signs Off | Verification Fails / Abort | |
| v v v |
| [ Simulated Remediation ] [ Escalate to SRE Lead ] [ Immutable Audit ] |
| Execute rollback sequence Notify secondary responder Full forensic log |
+-----------------------------------------------------------------------------------+Key Engineering Decisions & Trade-offs
Automated Pre-Ingestion Secret Redaction vs. Post-Processing Masking
Rationale: Production logs frequently contain sensitive authentication headers, database connection strings, and customer PII. Sanitizing payloads at the ingress boundary ensures sensitive data is never persisted to database stores or transmitted to external model APIs.
Trade-offs & Constraints: Requires maintaining comprehensive regex redaction patterns that slightly increase ingestion parsing latency.
Evidence-Grounded Separation (Facts vs. Interpretations) vs. Freeform AI Summaries
Rationale: Freeform LLM summaries often blend conjecture with empirical telemetry, confusing responders. Requiring explicit citations to specific log lines, trace spans, and metric timestamps builds operator trust and eliminates hallucinated root causes.
Trade-offs & Constraints: Prompts require structured JSON output constraints with rigid evidence-reference schemas.
Strict Operator Approval Boundary vs. Autonomous Self-Healing Remediation
Rationale: Allowing automated AI agents to execute destructive commands (e.g., pod restarts, database index drops, routing alterations) in production introduces unacceptable systemic risk. Enforcing operator review, dry-run checks, and rollback scripts prevents catastrophic secondary failures.
Trade-offs & Constraints: Requires human operator presence during remediation rather than autonomous zero-touch recovery.
Automated Secret & PII Redaction Pipeline
Scans raw log strings and trace attributes against multi-class regex patterns, replacing credentials, API tokens, Authorization headers, and sensitive connection strings with redaction tokens.
const REDACTION_PATTERNS: Array<{ regex: RegExp; replacement: string }> = [
// Bearer and OAuth tokens
{ regex: /Bearer\s+[A-Za-z0-9_\-\.~+/]+=*/gi, replacement: 'Bearer [REDACTED_TOKEN]' },
// API Keys (AWS, GCP, generic hex/base64 strings)
{ regex: /(api[-_]?key|secret|password|auth[-_]?token)\s*[:=]\s*['"]?[A-Za-z0-9_\-]{16,}['"]?/gi, replacement: '$1: [REDACTED_SECRET]' },
// Database connection URIs
{ regex: /(postgres|mysql|mongodb):\/\/[^:]+:[^@]+@/gi, replacement: '$1://[USER]:[PASSWORD]@' },
// Credit cards and SSN-like numeric tokens
{ regex: /\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b/g, replacement: '[REDACTED_CARD]' },
{ regex: /\b\d{3}-\d{2}-\d{4}\b/g, replacement: '[REDACTED_SSN]' },
];
export function sanitizeTelemetryPayload(rawText: string): string {
if (!rawText) return '';
let sanitized = rawText;
for (const { regex, replacement } of REDACTION_PATTERNS) {
sanitized = sanitized.replace(regex, replacement);
}
return sanitized;
}Operator Approval Gate & Remediation State Machine
Enforces a strict state machine ensuring remediation plans transition through DRAFT -> DRY_RUN -> AWAITING_APPROVAL -> EXECUTING -> VERIFIED, strictly requiring operator sign-off and rollback verification.
export type RemediationState =
| 'DRAFT'
| 'DRY_RUN_PASSED'
| 'AWAITING_OPERATOR_APPROVAL'
| 'APPROVED'
| 'EXECUTED'
| 'ROLLED_BACK'
| 'FAILED';
export interface RemediationStep {
stepNumber: number;
action: string;
command: string;
isReadOnly: boolean;
rollbackCommand: string;
verificationQuery: string;
}
export interface RemediationPlan {
planId: string;
incidentId: string;
state: RemediationState;
riskLevel: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
steps: RemediationStep[];
approvedBy?: string;
approvalNotes?: string;
executedAt?: string;
}
export function approveRemediationPlan(
plan: RemediationPlan,
operatorId: string,
notes: string
): RemediationPlan {
if (plan.state !== 'AWAITING_OPERATOR_APPROVAL') {
throw new Error(`Cannot approve plan in state '${plan.state}'. Dry run required first.`);
}
if (!notes || notes.trim().length < 10) {
throw new Error('Operator approval requires detailed rationale (minimum 10 characters).');
}
return {
...plan,
state: 'APPROVED',
approvedBy: operatorId,
approvalNotes: notes,
};
}Reliability, Security & Operational Considerations
- •Strict recommendation-only safety boundary: AI cannot directly invoke destructive shell or infrastructure commands.
- •Comprehensive secret sanitization guarantees credentials are never persisted to long-term storage or dispatched to LLMs.
- •Mandatory rollback step validation: every recommended remediation step must specify a tested inverse rollback command.
- •Immutable investigation audit trail records all timeline modifications, evidence attachments, and operator sign-offs.
Lessons Learned
- ✓During outages, responders prioritize speed of verification over length of narrative: concise, evidence-linked bullet points are 5x more effective than essay-style explanations.
- ✓Correlating deployment markers with trace latency shifts accounts for over 70% of root-cause discoveries in modern microservice architectures.
Known Limitations & Future Architecture Roadmap
- →Direct bidirectional integrations with PagerDuty and incident Slack channels are planned for future iterations.
- →Automated eBPF network probe integration to capture real-time kernel packet drop evidence during network partition incidents.