Incident copilotfrom a Cloud Monitoring alert to a verified fix and a postmortem · the agent investigates and asks · a person approves the fix

Cloud Monitoring alert + webhookMCP gateway (project 1)approval gate (project 1)LLM door · Gemini 3.8 FlashKeycloak service accountPostgres LISTEN/NOTIFYReact live timelineTerraform

Repo: github.com/bhavishyajain545/gcp-ai-incident-copilot · rebuild: REBUILD.md · series: 1 MCP gateway · 2 LLM router · 3 n8n hub

Demo (narrated)

Measured on the recorded run

5.2 min
from the bad release to the Cloud Monitoring alert (restart_count, 60 s alignment); the copilot acknowledged in about a second
29 s
from the alert to a hypothesis with evidence and a rollback proposal (pods, the failing log, rollout history, events)
11 s
from the admin's approval to every replica ready again (rollback executed through the gated tool, verified by the copilot)
$0.014
what the copilot spent at the LLM door for the whole incident, postmortem included
0
fixes the copilot could apply on its own: it holds a role that may only request a restart or rollback; the gate waits for a person

How it works

The loop, step by step

stepwhat happenswhere
alertTerraform-managed policy on kubernetes.io/container/restart_count in demo-apps → webhook_tokenauth channel → /hooks/gcm?token=…; deduplicated, with a cooldown for the alert's own re-notificationsCloud Monitoring
investigateas service-account-copilot: list_pods, pod_logs, rollout_history (new: image, command, change-cause per revision), recent_events; one tool per stepMCP gateway
hypothesisGemini 3.8 Flash through the door: summary, impact, hypothesis, evidence, confidence, and a proposal or nullLLM door
approvalrollback_deployment answers APPROVAL REQUIRED: request A-…; the copilot re-sends the same call every 8 s; an admin approves in the consoleproject 1 gate
fix + verifythe approved call replaces the pod template with the previous revision's; the copilot checks every replica is readyMCP gateway
postmortemblameless Markdown from the timeline, for a person to editLLM door

Lessons

symptomcausefix
an empty incident appeared after the fixCloud Monitoring's closed notification went through the "open" patha close only annotates the incident it belongs to
a duplicate incident minutes after recoveryrestart metrics lag the fix; the policy re-notified30-minute cooldown per alert key
rollback would have kept the crasha merge patch keeps fields the bad revision addedJSON patch replace /spec/template, like rollout undo
<PERSON> in the postmortemthe door's guard masks names in answersthe prompt uses roles, not names
a resumed incident got 429the copilot is one tenant: 50k tokens per hour~12k tokens an incident; documented capacity
Built on GKE Autopilot in project bj-ai-platform · source