ai-sre-incident-response

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AI SRE Incident Response

AI SRE事件响应

Apply SRE rigor to AI systems where incidents include quality regressions, unsafe outputs, and budget explosions.
将SRE的严谨性应用于AI系统,应对包括质量退化、不安全输出和预算激增在内的事件。

When to Use This Skill

何时使用此技能

  • An LLM endpoint begins returning degraded or hallucinated answers
  • Token spend spikes beyond budget thresholds
  • A model provider goes down and traffic must fail over
  • Safety guardrails fire at abnormal rates
  • A new model deployment causes latency or accuracy regression
  • LLM端点开始返回质量下降或幻觉性回答
  • Token消耗超出预算阈值
  • 模型提供商服务中断,流量需要故障转移
  • 安全防护机制触发率异常
  • 新模型部署导致延迟或准确性退化

Prerequisites

前置条件

  • Prometheus and Alertmanager deployed with scrape targets for AI services
  • Grafana dashboards for golden signals (latency, error rate, cost, quality)
  • On-call rotation configured in PagerDuty, Opsgenie, or equivalent
  • Runbook repository accessible to responders
  • Rollback mechanism for model and prompt versions (GitOps or feature flags)
  • 已部署Prometheus和Alertmanager,并配置了AI服务的采集目标
  • 用于黄金指标(延迟、错误率、成本、质量)的Grafana仪表盘
  • 在PagerDuty、Opsgenie或同类工具中配置了轮值待命机制
  • 响应人员可访问的运行手册仓库
  • 模型和提示词版本的回滚机制(GitOps或功能标志)

AI Incident Classes

AI事件类别

  • Availability incident: model/provider unavailable, timeout storm.
  • Quality incident: answer accuracy or tool success drops below SLO.
  • Safety incident: harmful or policy-violating outputs increase.
  • Cost incident: unexpected token or provider spend spike.
  • 可用性事件:模型/提供商不可用、超时风暴。
  • 质量事件:回答准确性或工具成功率低于SLO。
  • 安全事件:有害或违反政策的输出增加。
  • 成本事件:Token或提供商费用意外激增。

Severity Framework

严重程度框架

SeverityCriteriaResponse TimeNotification
SEV1User-facing outage, compliance risk, data leak5 minPage on-call + incident commander
SEV2Major degradation in key flows15 minPage on-call
SEV3Limited impact or internal-only issue1 hourSlack alert
SEV4Cosmetic or low-priority regressionNext business dayTicket
严重程度判定标准响应时间通知方式
SEV1用户侧服务中断、合规风险、数据泄露5分钟呼叫待命人员 + 事件指挥官
SEV2关键流程严重退化15分钟呼叫待命人员
SEV3影响范围有限或仅内部问题1小时Slack告警
SEV4外观问题或低优先级退化下一个工作日工单

Golden Signals for AI Services

AI服务的黄金指标

  • Request success rate
  • Latency (queue + generation + tool execution)
  • Hallucination/groundedness proxy metrics
  • Cost per minute and per tenant
  • Guardrail violation rate
  • 请求成功率
  • 延迟(队列 + 生成 + 工具执行)
  • 幻觉/事实一致性代理指标
  • 每分钟及每个租户的成本
  • 防护机制违规率

Prometheus Alert Rules

Prometheus告警规则

yaml
undefined
yaml
undefined

prometheus-ai-alerts.yaml

prometheus-ai-alerts.yaml

groups:
  • name: ai-service-alerts rules:
    • alert: ModelEndpointDown expr: up{job="llm-inference"} == 0 for: 2m labels: severity: sev1 annotations: summary: "LLM inference endpoint {{ $labels.instance }} is down" runbook_url: "https://runbooks.internal/ai/model-outage"
    • alert: HighHallucinationRate expr: | rate(llm_hallucination_detected_total[10m]) / rate(llm_requests_total[10m]) > 0.15 for: 5m labels: severity: sev2 annotations: summary: "Hallucination rate above 15% for {{ $labels.model }}" runbook_url: "https://runbooks.internal/ai/quality-regression"
    • alert: TokenCostExplosion expr: | sum(rate(llm_token_cost_dollars[5m])) by (tenant)
      0.50 for: 3m labels: severity: sev2 annotations: summary: "Token spend exceeds $0.50/min for tenant {{ $labels.tenant }}" runbook_url: "https://runbooks.internal/ai/cost-spike"
    • alert: LatencyP95Exceeded expr: | histogram_quantile(0.95, rate(llm_request_duration_seconds_bucket[5m]) ) > 5 for: 5m labels: severity: sev2 annotations: summary: "LLM p95 latency exceeds 5s for {{ $labels.service }}"
    • alert: GuardrailViolationSpike expr: | rate(llm_guardrail_violations_total[10m]) / rate(llm_requests_total[10m]) > 0.05 for: 5m labels: severity: sev1 annotations: summary: "Guardrail violations above 5% for {{ $labels.model }}" runbook_url: "https://runbooks.internal/ai/safety-incident"
    • alert: ModelQualityDrop expr: | llm_eval_score{metric="groundedness"} < 0.70 for: 10m labels: severity: sev2 annotations: summary: "Groundedness score dropped below 0.70 for {{ $labels.model }}"
    • alert: ProviderErrorRateHigh expr: | rate(llm_provider_errors_total[5m]) / rate(llm_provider_requests_total[5m]) > 0.10 for: 3m labels: severity: sev2 annotations: summary: "Provider {{ $labels.provider }} error rate above 10%"
undefined
groups:
  • name: ai-service-alerts rules:
    • alert: ModelEndpointDown expr: up{job="llm-inference"} == 0 for: 2m labels: severity: sev1 annotations: summary: "LLM inference endpoint {{ $labels.instance }} is down" runbook_url: "https://runbooks.internal/ai/model-outage"
    • alert: HighHallucinationRate expr: | rate(llm_hallucination_detected_total[10m]) / rate(llm_requests_total[10m]) > 0.15 for: 5m labels: severity: sev2 annotations: summary: "Hallucination rate above 15% for {{ $labels.model }}" runbook_url: "https://runbooks.internal/ai/quality-regression"
    • alert: TokenCostExplosion expr: | sum(rate(llm_token_cost_dollars[5m])) by (tenant)
      0.50 for: 3m labels: severity: sev2 annotations: summary: "Token spend exceeds $0.50/min for tenant {{ $labels.tenant }}" runbook_url: "https://runbooks.internal/ai/cost-spike"
    • alert: LatencyP95Exceeded expr: | histogram_quantile(0.95, rate(llm_request_duration_seconds_bucket[5m]) ) > 5 for: 5m labels: severity: sev2 annotations: summary: "LLM p95 latency exceeds 5s for {{ $labels.service }}"
    • alert: GuardrailViolationSpike expr: | rate(llm_guardrail_violations_total[10m]) / rate(llm_requests_total[10m]) > 0.05 for: 5m labels: severity: sev1 annotations: summary: "Guardrail violations above 5% for {{ $labels.model }}" runbook_url: "https://runbooks.internal/ai/safety-incident"
    • alert: ModelQualityDrop expr: | llm_eval_score{metric="groundedness"} < 0.70 for: 10m labels: severity: sev2 annotations: summary: "Groundedness score dropped below 0.70 for {{ $labels.model }}"
    • alert: ProviderErrorRateHigh expr: | rate(llm_provider_errors_total[5m]) / rate(llm_provider_requests_total[5m]) > 0.10 for: 3m labels: severity: sev2 annotations: summary: "Provider {{ $labels.provider }} error rate above 10%"
undefined

Response Playbooks

响应运行手册

Model Outage Runbook

模型故障运行手册

text
TRIGGER: ModelEndpointDown fires for > 2 minutes
RESPONDER: On-call AI platform engineer

1. Acknowledge alert in PagerDuty.
2. Check provider status page (e.g., status.openai.com).
3. Verify network connectivity:
     curl -s -o /dev/null -w "%{http_code}" https://api.provider.com/health
4. If provider is down:
     a. Enable fallback model route in gateway config.
     b. kubectl set env deployment/llm-gateway FALLBACK_ENABLED=true
     c. Verify fallback traffic is flowing via Grafana dashboard.
5. If self-hosted model is down:
     a. Check pod status: kubectl get pods -l app=llm-inference -n ai
     b. Check GPU health: kubectl logs -l app=llm-inference --tail=50
     c. Restart if OOM: kubectl rollout restart deployment/llm-inference -n ai
6. Freeze all deployments:
     kubectl annotate deployment --all deploy-freeze=true -n ai
7. Communicate ETA in #incident-channel.
8. When resolved, unfreeze and run smoke tests.
text
TRIGGER: ModelEndpointDown触发超过2分钟
RESPONDER: 待命AI平台工程师

1. 在PagerDuty中确认告警。
2. 查看提供商状态页面(例如status.openai.com)。
3. 验证网络连通性:
     curl -s -o /dev/null -w "%{http_code}" https://api.provider.com/health
4. 如果提供商服务中断:
     a. 在网关配置中启用备用模型路由。
     b. kubectl set env deployment/llm-gateway FALLBACK_ENABLED=true
     c. 通过Grafana仪表盘验证备用流量是否正常流转。
5. 如果自托管模型服务中断:
     a. 检查Pod状态: kubectl get pods -l app=llm-inference -n ai
     b. 检查GPU健康状况: kubectl logs -l app=llm-inference --tail=50
     c. 如果是OOM导致,重启服务: kubectl rollout restart deployment/llm-inference -n ai
6. 冻结所有部署:
     kubectl annotate deployment --all deploy-freeze=true -n ai
7. 在#incident-channel中沟通预计恢复时间。
8. 故障解决后,解除冻结并运行冒烟测试。

Quality Regression Runbook (Hallucination Spike)

质量退化运行手册(幻觉激增)

text
TRIGGER: HighHallucinationRate or ModelQualityDrop fires
RESPONDER: On-call AI engineer + ML lead

1. Acknowledge alert. Open incident ticket.
2. Identify scope:
     - Which model version? Check deployment metadata.
     - Which routes/tenants affected? Filter by labels in Grafana.
3. Check recent changes:
     - Model version promotion in last 24h?
     - Prompt template changes in last 24h?
     - Retrieval index rebuild in last 24h?
4. If recent model change:
     kubectl rollout undo deployment/llm-inference -n ai
5. If recent prompt change:
     git revert <commit> && git push  # triggers GitOps redeploy
6. Increase trace sampling to 100% for affected route:
     kubectl set env deployment/llm-gateway TRACE_SAMPLE_RATE=1.0
7. Run offline eval suite against current production:
     python run_evals.py --target prod --suite quality --compare baseline
8. Confirm metrics return to baseline before closing.
text
TRIGGER: HighHallucinationRate或ModelQualityDrop触发
RESPONDER: 待命AI工程师 + ML负责人

1. 确认告警,创建事件工单。
2. 确定影响范围:
     - 哪个模型版本?查看部署元数据。
     - 哪些路由/租户受影响?在Grafana中按标签筛选。
3. 检查近期变更:
     - 过去24小时内是否有模型版本升级?
     - 过去24小时内是否有提示词模板变更?
     - 过去24小时内是否有检索索引重建?
4. 如果是近期模型变更:
     kubectl rollout undo deployment/llm-inference -n ai
5. 如果是近期提示词变更:
     git revert <commit> && git push  # 触发GitOps重新部署
6. 将受影响路由的追踪采样率提升至100%:
     kubectl set env deployment/llm-gateway TRACE_SAMPLE_RATE=1.0
7. 针对当前生产环境运行离线评估套件:
     python run_evals.py --target prod --suite quality --compare baseline
8. 确认指标恢复到基线后再关闭事件。

Token Cost Explosion Runbook

Token成本激增运行手册

text
TRIGGER: TokenCostExplosion fires
RESPONDER: On-call platform engineer

1. Identify top consumers:
     Query: topk(10, sum(rate(llm_token_cost_dollars[15m])) by (tenant, model, route))
2. Check for runaway loops:
     - Agent retry storms (exponential token growth per request)
     - Missing max_tokens caps on new routes
     - Cache bypass due to config change
3. Apply immediate caps:
     kubectl patch configmap llm-quotas -n ai --patch '
       data:
         max_tokens_per_request: "4096"
         rpm_limit: "60"
     '
4. Enable semantic cache if disabled:
     kubectl set env deployment/llm-gateway CACHE_ENABLED=true
5. Route traffic to cheaper model tier:
     kubectl set env deployment/llm-gateway DEFAULT_MODEL=gpt-4o-mini
6. Notify affected tenants of temporary limits.
7. Open postmortem with cost attribution analysis.
text
TRIGGER: TokenCostExplosion触发
RESPONDER: 待命平台工程师

1. 确定顶级消耗者:
     查询语句: topk(10, sum(rate(llm_token_cost_dollars[15m])) by (tenant, model, route))
2. 检查是否存在失控循环:
     - Agent重试风暴(每个请求的Token消耗呈指数增长)
     - 新路由缺少max_tokens上限
     - 配置变更导致缓存失效
3. 应用即时上限:
     kubectl patch configmap llm-quotas -n ai --patch '
       data:
         max_tokens_per_request: "4096"
         rpm_limit: "60"
     '
4. 如果语义缓存已禁用,启用它:
     kubectl set env deployment/llm-gateway CACHE_ENABLED=true
5. 将流量路由到更便宜的模型层级:
     kubectl set env deployment/llm-gateway DEFAULT_MODEL=gpt-4o-mini
6. 通知受影响的租户临时限制措施。
7. 启动事后复盘,进行成本归因分析。

Escalation Procedures

升级流程

text
Level 1 (0-15 min):  On-call AI platform engineer
Level 2 (15-30 min): AI platform team lead + affected product owner
Level 3 (30-60 min): Engineering director + security (if safety incident)
Level 4 (60+ min):   VP Engineering + legal (if compliance/data incident)

Safety incidents always start at Level 2 minimum.
Provider-side incidents: open support ticket immediately at Level 1.
text
Level 1 (0-15 min):  待命AI平台工程师
Level 2 (15-30 min): AI平台团队负责人 + 受影响产品负责人
Level 3 (30-60 min): 工程总监 + 安全团队(如果是安全事件)
Level 4 (60+ min):   工程副总裁 + 法务团队(如果是合规/数据事件)

安全事件始终从Level 2开始升级。
提供商侧事件: 在Level 1时立即提交支持工单。

Detection Queries (PromQL)

检测查询(PromQL)

promql
undefined
promql
undefined

Request success rate by model

Request success rate by model

1 - ( sum(rate(llm_requests_total{status="error"}[5m])) by (model) / sum(rate(llm_requests_total[5m])) by (model) )
1 - ( sum(rate(llm_requests_total{status="error"}[5m])) by (model) / sum(rate(llm_requests_total[5m])) by (model) )

Cost per successful answer

Cost per successful answer

sum(rate(llm_token_cost_dollars[5m])) by (route) / sum(rate(llm_requests_total{status="success"}[5m])) by (route)
sum(rate(llm_token_cost_dollars[5m])) by (route) / sum(rate(llm_requests_total{status="success"}[5m])) by (route)

Hallucination rate trend (1h window, 5m steps)

Hallucination rate trend (1h window, 5m steps)

rate(llm_hallucination_detected_total[1h]) / rate(llm_requests_total[1h])
rate(llm_hallucination_detected_total[1h]) / rate(llm_requests_total[1h])

Latency breakdown by stage

Latency breakdown by stage

histogram_quantile(0.95, rate(llm_retrieval_duration_seconds_bucket[5m])) histogram_quantile(0.95, rate(llm_generation_duration_seconds_bucket[5m])) histogram_quantile(0.95, rate(llm_tool_execution_duration_seconds_bucket[5m]))
histogram_quantile(0.95, rate(llm_retrieval_duration_seconds_bucket[5m])) histogram_quantile(0.95, rate(llm_generation_duration_seconds_bucket[5m])) histogram_quantile(0.95, rate(llm_tool_execution_duration_seconds_bucket[5m]))

Tenant cost leaderboard

Tenant cost leaderboard

topk(10, sum(rate(llm_token_cost_dollars[1h])) by (tenant))
undefined
topk(10, sum(rate(llm_token_cost_dollars[1h])) by (tenant))
undefined

Postmortem Requirements

事后复盘要求

  • Timeline with detector and responder timestamps
  • Blast radius by tenant and feature
  • Missed signals and alert tuning actions
  • Concrete hardening tasks with owners and due dates
  • Cost impact (dollars, tokens, affected requests)
  • Customer communication log
  • 包含检测和响应时间戳的时间线
  • 按租户和功能划分的影响范围
  • 遗漏的信号和告警调优措施
  • 明确的加固任务,包含负责人和截止日期
  • 成本影响(金额、Token、受影响请求数)
  • 客户沟通记录

Postmortem Template

事后复盘模板

markdown
undefined
markdown
undefined

Incident Summary

事件摘要

  • Severity: SEVx
  • Duration: start_time - end_time (Xh Ym)
  • Detection: How was it detected? (alert / customer report / manual)
  • Impact: X tenants, Y requests, $Z cost
  • Severity: SEVx
  • Duration: start_time - end_time (Xh Ym)
  • Detection: How was it detected? (alert / customer report / manual)
  • Impact: X tenants, Y requests, $Z cost

Timeline

Timeline

Time (UTC)Event
HH:MMAlert fired
HH:MMResponder acknowledged
HH:MMRoot cause identified
HH:MMMitigation applied
HH:MMIncident resolved
Time (UTC)Event
HH:MMAlert fired
HH:MMResponder acknowledged
HH:MMRoot cause identified
HH:MMMitigation applied
HH:MMIncident resolved

Root Cause

Root Cause

[Description]
[Description]

Action Items

Action Items

ActionOwnerDue DateStatus
Tune alert threshold@engineerYYYY-MM-DDOpen
Add fallback route@platformYYYY-MM-DDOpen
undefined
ActionOwnerDue DateStatus
Tune alert threshold@engineerYYYY-MM-DDOpen
Add fallback route@platformYYYY-MM-DDOpen
undefined

Chaos Engineering for AI Systems

AI系统混沌工程

Regularly test incident readiness:
  • Provider failover drill: block provider API at network level, verify fallback activates within SLO.
  • Model rollback drill: deploy known-bad model version, verify automated quality gate catches it.
  • Cost cap drill: simulate runaway token usage, verify quotas trigger before budget threshold.
  • Cache failure drill: disable semantic cache, verify system degrades gracefully.
定期测试事件响应准备情况:
  • 提供商故障转移演练: 在网络层阻断提供商API,验证备用机制在SLO内激活。
  • 模型回滚演练: 部署已知有问题的模型版本,验证自动化质量网关能检测到。
  • 成本上限演练: 模拟Token消耗失控场景,验证配额在预算阈值前触发。
  • 缓存故障演练: 禁用语义缓存,验证系统优雅降级。

Troubleshooting

故障排查

SymptomCheckFix
All requests timing outProvider status page, DNS resolutionEnable fallback provider
Gradual quality declineRecent model/prompt deploymentsRoll back to last known good
Sudden cost spikePer-tenant token usage dashboardApply emergency token caps
Guardrail violations spikeModel version, prompt injection logsEnable stricter input filtering
Intermittent 503 errorsPod restarts, GPU OOM eventsIncrease memory limits or reduce batch size
症状检查项修复方案
所有请求超时提供商状态页面、DNS解析启用备用提供商
质量逐渐下降近期模型/提示词部署回滚到上一个已知正常版本
成本突然激增按租户划分的Token使用仪表盘应用紧急Token上限
防护机制违规激增模型版本、提示词注入日志启用更严格的输入过滤
间歇性503错误Pod重启、GPU OOM事件增加内存限制或减小批量大小

Related Skills

相关技能

  • incident-response - Standard incident process and evidence
  • alerting-oncall - Paging and escalation policy
  • llm-cost-optimization - Spend controls and efficiency patterns
  • agent-observability - Instrument requests, traces, and costs
  • rag-observability-evals - RAG quality monitoring
  • incident-response - 标准事件流程和证据
  • alerting-oncall - 呼叫和升级政策
  • llm-cost-optimization - 费用控制和效率模式
  • agent-observability - 请求、追踪和成本监控
  • rag-observability-evals - RAG质量监控