選項
首頁首頁 Skill 開發營運和 CI/CD sentry-incident-runbook

使用 Sentry 的事件應變程序。適用於調查生產環境問題、進行錯誤分級,或建立事件應變工作流程。可透過「sentry 事件應變」、「sentry 錯誤分級」、「調查 sentry 錯誤」、「sentry 應變手冊」等短語觸發此流程。

...展開全部
48
更新時間 2026-07-01

關於sentry-incident-runbook

「sentry-incident-runbook 」這項技能旨在簡化 Sentry 內的事件應變流程。它能協助使用者以結構化且高效的方式調查生產環境問題、對錯誤進行分級處理,並建立事件應變工作流程。透過與 Sentry 整合,此技能簡化了從事件偵測到解決的整個管理流程,確保能以系統化方式處理關鍵錯誤,並將系統停機時間降至最低。 此技能對於負責維護生產環境可靠性的團隊至關重要,能讓他們迅速且有效地應對問題。

主要功能包括:使用 P0-P3 框架分類事件嚴重性、透過詳細檢查清單對事件進行分級,以及運用 Sentry 的 API 指令來蒐集問題詳情與事件資料。 此外,此技能還能根據錯誤性質(無論是部署問題、第三方故障、資料損毀或資源耗盡),協助應用預先定義的解決步驟。使用者亦可透過預建範本記錄調查結果、生成事後分析報告,並通報事件狀態。 目標使用者為需要及時且有系統地管理生產環境問題與錯誤的團隊,以確保遵循工作流程,並使每起事件都能獲得妥善記錄與解決。

「sentry-incident-runbook 」非常適合 DevOps 工程師、事件應變人員,以及任何參與錯誤管理與疑難排解的技術團隊。在快速回應與清晰記錄對於防止問題重演及維持生產系統順暢運作至關重要的環境中,此技能尤為實用。

常見問題

使用此技能有哪些先決條件?

您需要一個具備專案問題存取權限的 Sentry 帳戶、已針對嚴重錯誤設定的警示規則、已設定的團隊通知管道(例如 Slack、PagerDuty),並需了解錯誤嚴重性分類。

如何分類事件的嚴重性?

事件嚴重性是根據錯誤發生率及對使用者的影響,採用 P0-P3 框架進行分類。P0 為最高嚴重性等級,表示發生了關鍵問題。

如果沒有有效的 Sentry 帳戶,能否使用此技能?

不行,您必須擁有一個可存取專案問題的 Sentry 帳戶,才能有效使用此技能。

使用此技能管理事件時,是否有任何類型上的限制?

此技能專為處理 Sentry 中追蹤的事件而設計,但其功能僅限於 Sentry 所支援的範圍,例如錯誤模式偵測與嚴重性分類。

事件解決後會發生什麼情況?

事件解決後,此技能會協助生成事後分析報告,並記錄根本原因、解決時程及其他相關發現。

在 GitHub 上查看

Sentry Incident Runbook

Overview

Structured incident response framework built on Sentry's error monitoring platform. Covers the full lifecycle from alert detection through severity classification, root cause investigation using Sentry's breadcrumbs and stack traces, Discover queries for impact analysis, stakeholder communication, resolution via the Sentry API, and postmortem documentation with Sentry data exports.

Prerequisites

  • Sentry account with project-level access and auth token (SENTRY_AUTH_TOKEN)
  • Organization slug (SENTRY_ORG) and project slug (SENTRY_PROJECT) configured
  • @sentry/node (v8+) or equivalent SDK installed in the application
  • Alert rules configured for critical error thresholds
  • Notification channels connected (Slack integration or PagerDuty)

Instructions

Step 1 — Classify Severity

Assign a severity level based on error frequency and user impact. This determines response time and escalation path.

SeverityError CriteriaUser ImpactResponse TimeEscalation
P0 — CriticalCrash-free rate below 95% or unhandled exception spike >500/minCore flow blocked for all users, data loss risk15 minutesPagerDuty page to on-call engineer
P1 — MajorNew issue affecting >100 unique users per hourKey feature degraded, no workaround1 hourSlack #incidents channel, tag team lead
P2 — MinorNew issue affecting <100 unique users per hourFeature degraded but workaround existsSame business daySlack #alerts-production
P3 — LowEdge case, cosmetic error, staging-only issueMinimal or no user-facing impactNext sprintAdd to backlog, assign owner

Decision logic for classification:

Alert fires →├── Check crash-free rate (Project Settings → Crash Free Sessions)│   └── Below 95%? → P0├── Check unique users affected (Issue Details → Users tab)│   ├── >100/hr on core flow? → P1│   └── <100/hr or workaround exists? → P2└── Staging-only or edge case? → P3

Step 2 — Triage and Investigate

Execute this checklist within the first 15 minutes of a P0/P1 alert.

Initial triage (Sentry UI):

  1. Open the Sentry issue link from the alert notification
  2. Check the error frequency graph — determine if the rate is spiking, steady, or declining
  3. Read the "First Seen" and "Last Seen" timestamps to determine if this is new or a regression
  4. Check the "Users" count on the issue to quantify impact
  5. Verify the environment filter — confirm this is production, not staging
  6. Check the "Release" tag — identify which deployment introduced the error
  7. Open "Suspect Commits" to find the likely-causal changeset

Deep investigation (stack trace and breadcrumbs):

  1. Read the full stack trace — identify the failing function and line number
  2. Expand the breadcrumbs panel — trace the sequence of events leading to the error (HTTP requests, console logs, navigation, UI clicks)
  3. Check the user context panel for device, browser, OS, and custom user tags
  4. Review the "Tags" panel for patterns (specific release, region, browser)

API-based investigation:

# Fetch issue details programmaticallycurl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \  "https://sentry.io/api/0/organizations/$SENTRY_ORG/issues/$ISSUE_ID/" \  | python3 -c "import json, sysissue = json.load(sys.stdin)print(f'Title:      {issue[\"title\"]}')print(f'First Seen: {issue[\"firstSeen\"]}')print(f'Last Seen:  {issue[\"lastSeen\"]}')print(f'Events:     {issue[\"count\"]}')print(f'Users:      {issue[\"userCount\"]}')print(f'Level:      {issue[\"level\"]}')print(f'Status:     {issue[\"status\"]}')print(f'Platform:   {issue.get(\"platform\", \"unknown\")}')" || echo "ERROR: Failed to fetch issue — check SENTRY_AUTH_TOKEN and ISSUE_ID"# Fetch latest events for the issue (most recent 5)curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \  "https://sentry.io/api/0/organizations/$SENTRY_ORG/issues/$ISSUE_ID/events/?per_page=5" \  | python3 -c "import json, sysevents = json.load(sys.stdin)for e in events:    release = e.get('release', {})    ver = release.get('version', 'N/A') if isinstance(release, dict) else 'N/A'    print(f'Event {e[\"eventID\"][:12]} | {e.get(\"dateCreated\", \"N/A\")} | Release: {ver}')" || echo "ERROR: Failed to fetch events"

Sentry Discover queries for impact analysis:

# Count total events and unique affected users in last 24 hourscurl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \  "https://sentry.io/api/0/organizations/$SENTRY_ORG/events/" \  --data-urlencode "field=count()" \  --data-urlencode "field=count_unique(user)" \  --data-urlencode "query=issue.id:$ISSUE_ID" \  --data-urlencode "statsPeriod=24h" \  -G | python3 -c "import json, sysdata = json.load(sys.stdin)if 'data' in data and data['data']:    row = data['data'][0]    print(f'Events (24h):       {row.get(\"count()\", \"N/A\")}')    print(f'Unique users (24h): {row.get(\"count_unique(user)\", \"N/A\")}')" || echo "ERROR: Discover query failed"# Check p95 transaction duration for affected endpointcurl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \  "https://sentry.io/api/0/organizations/$SENTRY_ORG/events/" \  --data-urlencode "field=transaction" \  --data-urlencode "field=p95(transaction.duration)" \  --data-urlencode "field=count()" \  --data-urlencode "query=has:transaction event.type:transaction" \  --data-urlencode "statsPeriod=1h" \  --data-urlencode "sort=-count()" \  --data-urlencode "per_page=5" \  -G | python3 -c "import json, sysdata = json.load(sys.stdin)if 'data' in data:    for row in data['data']:        txn = row.get('transaction', 'unknown')        p95 = row.get('p95(transaction.duration)', 0)        cnt = row.get('count()', 0)        print(f'{txn}: p95={p95:.0f}ms, count={cnt}')" || echo "ERROR: Transaction query failed"

Step 3 — Resolve, Communicate, and Document

Identify the root cause pattern:

PatternDiagnostic SignalImmediate Action
Deployment regression"First Seen" aligns with latest deploy timestampRollback via sentry-cli releases deploys $PREV_VERSION new --env production
Third-party failureBreadcrumbs show failed HTTP calls to external hostsEnable circuit breaker, add retry logic, monitor dependency status
Data corruptionEvent context contains malformed input samplesAdd input validation, fix data pipeline upstream
Resource exhaustionError rate correlates with traffic spikes (OOM, pool exhaustion)Scale horizontally, add connection pooling, implement rate limiting
SDK misconfigurationEvents missing context, breadcrumbs, or release infoReview Sentry.init() options, verify source maps uploaded

Resolve the issue via Sentry API:

# Mark issue as resolved (closes the issue)curl -s -X PUT \  -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \  -H "Content-Type: application/json" \  -d '{"status": "resolved"}' \  "https://sentry.io/api/0/organizations/$SENTRY_ORG/issues/$ISSUE_ID/" \  | python3 -c "import json,sys; d=json.load(sys.stdin); print(f'Status: {d.get(\"status\",\"unknown\")}')" \  || echo "ERROR: Failed to resolve issue"# Resolve in next release (auto-reopens on regression)curl -s -X PUT \  -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \  -H "Content-Type: application/json" \  -d '{"status": "resolved", "statusDetails": {"inNextRelease": true}}' \  "https://sentry.io/api/0/organizations/$SENTRY_ORG/issues/$ISSUE_ID/" \  | python3 -c "import json,sys; d=json.load(sys.stdin); print(f'Status: {d.get(\"status\",\"unknown\")} (regression detection enabled)')" \  || echo "ERROR: Failed to resolve issue"# Ignore with threshold (snooze until count exceeds limit)# Use 100 as the re-alert threshold for noisy low-severity issuescurl -s -X PUT \  -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \  -H "Content-Type: application/json" \  -d '{"status": "ignored", "statusDetails": {"ignoreCount": 100}}' \  "https://sentry.io/api/0/organizations/$SENTRY_ORG/issues/$ISSUE_ID/" \  | python3 -c "import json,sys; d=json.load(sys.stdin); print(f'Status: {d.get(\"status\",\"unknown\")} (snoozed until 100 events)')" \  || echo "ERROR: Failed to ignore issue"

Stakeholder communication templates:

Initial alert (send within 15 minutes of P0):

INCIDENT — [Service Name]Status: InvestigatingImpact: [Description of user-facing symptoms]Started: [Timestamp from Sentry "First Seen"]Sentry Issue: [Link to issue]Incident Lead: @[on-call engineer]Next update: 30 minutes

Resolution notice:

RESOLVED — [Service Name]Duration: [Total incident time from first alert to resolution]Root Cause: [One-line description from investigation]Fix Applied: [What changed — rollback, hotfix, config change]Postmortem: [Link — due within 48 hours]

Postmortem template with Sentry data:

## Incident Postmortem: [Title from Sentry Issue]### Timeline- [HH:MM] Alert fired — Sentry issue [ISSUE_ID] created- [HH:MM] On-call engineer acknowledged- [HH:MM] Root cause identified via [breadcrumbs / stack trace / suspect commits]- [HH:MM] Fix deployed — [rollback / hotfix description]- [HH:MM] Error rate returned to baseline, issue resolved in Sentry### Impact (from Sentry Discover)- **Duration:** [X hours Y minutes]- **Total events:** [count() from Discover query]- **Unique users affected:** [count_unique(user) from Discover query]- **p95 latency during incident:** [p95(transaction.duration) from Discover]### Root Cause (5 Whys)1. Why did the error occur? [Direct cause from stack trace]2. Why was that code path triggered? [From breadcrumbs]3. Why was it not caught in testing? [Gap analysis]4. Why did the alert take [X] minutes? [Alert rule review]5. Why is this class of error possible? [Systemic cause]### Action Items- [ ] [Preventive measure] — Owner: @[name] — Due: [date]- [ ] Update Sentry alert rules to catch [pattern] earlier- [ ] Add regression test covering [scenario from breadcrumbs]- [ ] Review and tighten ownership rules for [component]

Output

  • Severity classification (P0-P3) based on error frequency and user impact
  • Completed triage checklist with root cause identification
  • Sentry Discover query results quantifying incident impact
  • API-driven issue resolution with regression detection enabled
  • Stakeholder communication messages (initial alert + resolution)
  • Postmortem document populated with Sentry data exports

Error Handling

ErrorCauseSolution
401 Unauthorized from Sentry APIAuth token expired or lacks org-level scopeRegenerate token at Settings > Developer Settings > Internal Integrations with event:read, issue:write scopes
Alert fatigue — too many P2/P3 alertsAlert rules trigger on every event instead of thresholdsChange alert condition to "New issue" or "Event frequency > N in M minutes"
Suspect Commits shows wrong commitRelease association not configuredRun sentry-cli releases set-commits --auto in CI pipeline
Missing breadcrumbs in eventsSDK not capturing HTTP/console/navigation breadcrumbsVerify Sentry.init({ integrations: [breadcrumbsIntegration()] }) and check maxBreadcrumbs setting
Issue keeps regressing after resolveRoot cause not fully addressed, only symptom fixedUse "Resolve in next release" for auto-reopen, add regression test
Discover query returns empty dataWrong time range or missing event.type filterExpand statsPeriod to 7d, verify query syntax in Sentry Discover UI first

Examples

Example 1 — P0 payment failure spike:

An alert fires: PaymentProcessingError with 200 events in 5 minutes. Triage reveals crash-free rate dropped to 91%. Breadcrumbs show the Stripe webhook handler receiving malformed payloads after a Stripe API version change. Suspect Commits points to a dependency update merged 20 minutes ago. Resolution: rollback the deployment, resolve the Sentry issue with inNextRelease, file a postmortem with the 5 Whys showing the missing Stripe API version pin.

Example 2 — P2 intermittent 503 from upstream API:

Sentry shows ServiceUnavailableError affecting 40 users/hour. Discover query reveals count() = 180, count_unique(user) = 40, p95(transaction.duration) = 8200ms. Breadcrumbs show the third-party geocoding API returning 503. Resolution: enable the circuit breaker fallback to cached results, ignore the Sentry issue with ignoreCount: 100, create a backlog item to add a secondary geocoding provider.

Example 3 — P1 new unhandled exception after deploy:

A TypeError: Cannot read properties of undefined appears immediately after a release tagged v2.4.1. First Seen matches the deploy timestamp. Stack trace points to a renamed API response field. Suspect Commits identifies the exact PR. Resolution: deploy hotfix renaming the field access, resolve the issue tied to v2.4.2, update the postmortem with Discover data showing 320 affected users over 45 minutes.

Resources

  • Sentry Issue Details — anatomy of an issue page
  • Sentry Alerts — configuring alert rules and thresholds
  • Sentry Discover Queries — building impact analysis queries
  • Issues API — programmatic issue management
  • Ownership Rules — auto-assigning issues to teams
  • @sentry/node SDK — Node.js SDK configuration

Next Steps

For configuring Sentry alerts and error capture, see sentry-error-capture. For CI/CD integration with Sentry releases, see sentry-ci-integration. For performance monitoring and tracing, see sentry-performance-tracing.

所有檔案

1 個檔案

安裝 sentry-incident-runbook

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/main/plugins/saas-packs/sentry-pack/skills/sentry-incident-runbook/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/,Claude 會自動偵測並使用該技能

相關技能

base44-cli
更新時間 2026-06-29
klingai-upgrade-migration
更新時間 2026-07-03
Railway CLI Management
更新時間 2026-07-02
Verification &amp; Quality Assurance
更新時間 2026-06-29
OR