Incident response
Severity levels, alert routing and paging, the runbook for SuggestionFailureBudgetBurn, and the review after an incident.
Severity levels
| Level | Meaning | Example | Response |
|---|---|---|---|
| SEV1 | Most users cannot load, save or get suggestions, or document data may be exposed | Every task unhealthy; a leaked key | Page now, around the clock. One incident lead. Status updates every 30 minutes. |
| SEV2 | A core path is degraded and the error budget burns fast | SuggestionFailureBudgetBurn, 5xx ratio above 5% |
Page now. Mitigate first (roll back, switch the model), diagnose after. |
| SEV3 | Degraded but not urgent, or one customer affected | p95 response time alarm, an Aurora alarm | A ticket for working hours. No page. |
Alert routing
- Built. Every alarm goes to one SNS topic (
infrastructure/modules/observability). The topic has one email subscription, andalarm_emailisnullin every environment today, so nobody is notified yet. - Described, not built. A PagerDuty integration subscribed to the topic. The on-call is the engineering team, on a weekly rotation. SEV1 and SEV2 alarms page. SEV3 alarms open a ticket, which needs a second topic or PagerDuty event rules to tell them apart; today all alarms share one topic.
- Locally there is no Alertmanager. The alert shows on
http://localhost:9090/alertsand nothing is sent.
Runbook: SuggestionFailureBudgetBurn
What it means
More than 7.2% of AI suggestion requests ended as ai_error or invalid_response, in both the last hour and the last 5 minutes. At this rate the 30-day error budget of the 99.5% objective is gone in about 2 days. Users type and get no suggestions, with no error shown: the handler sends nothing on failure. The page loads, so nothing else looks wrong.
In AWS the same condition is the alarm <name>-suggestion-failure-ratio (5-minute window only). During a release it also rolls the release back.
First checks (5 minutes)
- Did a release just go out? Check the latest GitHub Deployment for the environment and the
deploy.ymlrun. If the alarm fired during a rollout, ECS has probably already rolled it back;verify-deployment.shturns the job red. - Dashboard
Patent server: suggestions:- Panel Suggestion requests by outcome: is it
ai_errororinvalid_response? Didokdrop to zero, or only partly? - Panel Suggestion failure ratio vs objective: when did the 5m line cross the 7.2% threshold line?
- Panel Suggestion duration p50 and p95: are failures fast (rejected) or slow (timeouts)?
- Panel Suggestions in flight: a rising line with few completions means calls hang.
- Panel Suggestion requests by outcome: is it
- Which error. In CloudWatch Logs Insights on
/ecs/<name>-server:fields @timestamp, outcome, `error.type`, trace_id | filter event = "suggestion.failed" | stats count() by `error.type`, outcome - One failing trace. Take a
trace_idfrom that query. In X-Ray, filter withannotation.suggestions_outcome = "ai_error". Locally in Jaeger, search servicepatent-server, operationsuggestions.review, tagssuggestions.outcome=ai_error. The childPOSTspan shows OpenAI’s HTTP status.
Likely causes
error.type |
Outcome | Likely cause | Action |
|---|---|---|---|
NotFoundError |
ai_error |
OPENAI_MODEL names a model that does not exist or was retired |
Revert the openai_model change in Terraform, then release |
AuthenticationError, PermissionDeniedError |
ai_error |
The key in Secrets Manager was rotated, revoked or emptied | Put a valid key; replace tasks (secrets are read at task start) |
RateLimitError |
ai_error |
OpenAI quota or tokens per minute | Raise the quota; check for a traffic spike in requests by outcome |
APITimeoutError, APIConnectionError, InternalServerError |
ai_error |
OpenAI outage, or egress (NAT) failure | Check the OpenAI status page and NAT gateway metrics. A rollback does not help. |
ValidationError |
invalid_response |
The model returns JSON that does not fit Suggestions: a prompt or model change |
Roll back the release that changed it |
Roll back
- Caused by a release: run
rollback.ymlfor the environment with a reason. It re-releases the last successful SHA and freezes deploys. See Rollback. - Caused by configuration (
openai_model, the key): revert in Terraform. A task definition change reaches the tasks only with the next release, so rundeploy.ymlafter the apply. - Caused by OpenAI: nothing to roll back. Post on the status page, and keep the alert open until the 5-minute window recovers.
- An alarm already in
ALARMwhen a deployment starts is not watched by ECS for that deployment, so a fix-forward release during the incident has no alarm rollback.
Resolution
The alert clears when the 5-minute ratio drops below 7.2%. Measured locally, that took about 5 minutes after the fix, as the failures aged out of the window.
After an incident
Every SEV1 and SEV2 gets a written, blameless review within five working days. The template has five parts:
- Timeline. First bad event, detection, page, mitigation, resolution, from the alarm history and the release records.
- Impact. Failed requests and budget spent, from
suggestions.requestsby outcome. - Causes and the contributing gaps. For example, a change with no staging soak, or a missing alarm.
- Actions. Each one has an owner and a date, and lands as a pull request or an issue.
- Alert check. Did the alert fire early enough, and was it actionable? Tune the threshold or the runbook in the same review.