sentry-create-alert
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Sentry Alert
创建 Sentry 告警
Create alerts via Sentry’s workflow engine API.
Note: This API is currently in beta and may be subject to change.
It is part of New Monitors and Alerts and may not be viewable in the legacy Alerts UI.
通过 Sentry 的 workflow engine API 创建告警。
注意: 此 API 当前仍处于 beta 阶段,可能会发生变化。
它属于 New Monitors and Alerts,可能无法在旧版 Alerts UI 中查看。
Invoke This Skill When
调用此 Skill 的时机
- User asks to “create a Sentry alert” or “set up notifications”
- User wants to be emailed or notified when issues match certain conditions
- User mentions priority alerts, de-escalation alerts, or workflow automations
- User wants to configure Slack, PagerDuty, or email notifications for Sentry issues
- 用户要求“创建 Sentry 告警”或“设置通知”
- 希望在 issue 符合特定条件时收到电子邮件或通知
- 提到优先级告警、优先级降级告警或工作流自动化
- 希望为 Sentry issue 配置 Slack、PagerDuty 或电子邮件通知
Prerequisites
前置条件
- available in shell
curl - Sentry org auth token with scope (also accepts
alerts:writeororg:admin)org:write
- shell 中可使用
curl - Sentry org auth token,需具备 scope(也接受
alerts:write或org:admin)org:write
Phase 1: Gather Configuration
阶段 1:收集配置
Ask the user for any missing details:
| Detail | Required | Example |
|---|---|---|
| Org slug | Yes | |
| Auth token | Yes | |
| Region | Yes (default: | |
| Alert name | Yes | |
| Trigger events | Yes | Which issue events fire the workflow |
| Conditions | Optional | Filter conditions before actions execute |
| Action type | Yes | |
| Action target | Yes | User email, team, channel, or service |
询问用户是否缺少以下必要信息:
| 详细信息 | 是否必填 | 示例 |
|---|---|---|
| Org slug | 是 | |
| Auth token | 是 | |
| Region | 是(默认: | |
| 告警名称 | 是 | |
| 触发事件 | 是 | 哪些 issue 事件触发工作流 |
| 条件 | 可选 | 在执行 actions 前应用的筛选条件 |
| 操作类型 | 是 | |
| 操作目标 | 是 | 用户电子邮件、团队、频道或服务 |
Phase 2: Look Up IDs
阶段 2:查询 ID
Use these API calls to resolve names to IDs as needed.
bash
API="https://{region}.sentry.io/api/0/organizations/{org}"
AUTH="Authorization: Bearer {token}"根据需要使用以下 API 调用将名称解析为 ID。
bash
API="https://{region}.sentry.io/api/0/organizations/{org}"
AUTH="Authorization: Bearer {token}"Find user ID by email
Find user ID by email
curl -s "$API/members/" -H "$AUTH" | python3 -c "
import json,sys
for m in json.load(sys.stdin):
if m.get('email')=='USER_EMAIL' or m.get('user',{}).get('email')=='USER_EMAIL':
print(m['user']['id']); break"
curl -s "$API/members/" -H "$AUTH" | python3 -c "
import json,sys
for m in json.load(sys.stdin):
if m.get('email')=='USER_EMAIL' or m.get('user',{}).get('email')=='USER_EMAIL':
print(m['user']['id']); break"
List teams
List teams
curl -s "$API/teams/" -H "$AUTH" | python3 -c "
import json,sys
for t in json.load(sys.stdin):
print(t['id'], t['slug'])"
curl -s "$API/teams/" -H "$AUTH" | python3 -c "
import json,sys
for t in json.load(sys.stdin):
print(t['id'], t['slug'])"
List integrations (for Slack/PagerDuty)
List integrations (for Slack/PagerDuty)
curl -s "$API/integrations/" -H "$AUTH" | python3 -c "
import json,sys
for i in json.load(sys.stdin):
print(i['id'], i['provider']['key'], i['name'])"
undefinedcurl -s "$API/integrations/" -H "$AUTH" | python3 -c "
import json,sys
for i in json.load(sys.stdin):
print(i['id'], i['provider']['key'], i['name'])"
undefinedPhase 3: Build Payload
阶段 3:构建 Payload
Trigger Events
触发事件
Pick which issue events fire the workflow.
Use (triggers must always use this).
logicType: "any-short"| Type | Fires when |
|---|---|
| New issue created |
| Resolved issue recurs |
| Archived issue reappears |
| Issue is resolved |
选择哪些 issue 事件触发工作流。
使用 (触发器必须始终使用此值)。
logicType: "any-short"| 类型 | 触发时机 |
|---|---|
| 创建新 issue |
| 已解决的 issue 再次发生 |
| 已归档的 issue 再次出现 |
| issue 已解决 |
Filter Conditions
筛选条件
Conditions that must pass before actions execute.
Use , , or .
logicType: "all""any-short""none"The field is polymorphic — its shape depends on the condition :
comparisontype| Type | | Description |
|---|---|---|
| | Priority >= Low(25)/Medium(50)/High(75) |
| | Priority dropped below peak |
| | Event count in time window |
| | Affected users in time window |
| | Event tag matches |
| | Issue assigned to target |
| | Event level (fatal=50, error=40, warning=30) |
| | Issue age |
| | Category (1=Error, 6=Feedback, 10=Outage: uptime and cron) |
| | Total occurrence count |
Interval options: , , , , , ,
"1min""5min""15min""1hr""1d""1w""30d"Tag match types: (contains), (not contains), , ,
(starts with), (ends with), (set), (not set)
"co""nc""eq""ne""sw""ew""is""ns"Set to to invert (fire when condition is NOT met).
conditionResultfalse执行 actions 前必须满足的条件。
使用 、 或 。
logicType: "all""any-short""none"comparisontype| 类型 | | 说明 |
|---|---|---|
| | 优先级 >= Low(25)/Medium(50)/High(75) |
| | 优先级降至峰值以下 |
| | 时间窗口内的事件计数 |
| | 时间窗口内受影响的用户数 |
| | 事件 tag 匹配 |
| | issue 已分配给目标对象 |
| | 事件级别(fatal=50、error=40、warning=30) |
| | issue 存续时长 |
| | 类别(1=Error,6=Feedback,10=Outage: uptime and cron) |
| | 总发生次数 |
间隔选项: 、、、、、、
"1min""5min""15min""1hr""1d""1w""30d"Tag 匹配类型: (包含)、(不包含)、、、
(以...开头)、(以...结尾)、(已设置)、(未设置)
"co""nc""eq""ne""sw""ew""is""ns"将 设为 可反转条件(在条件不满足时触发)。
conditionResultfalseActions
操作
| Type | Key Config |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| 类型 | 关键配置 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
Full Payload Structure
完整 Payload 结构
json
{
"name": "<Alert Name>",
"enabled": true,
"environment": null,
"config": { "frequency": 30 },
"triggers": {
"logicType": "any-short",
"conditions": [
{ "type": "first_seen_event", "comparison": true, "conditionResult": true }
],
"actions": []
},
"actionFilters": [{
"logicType": "all",
"conditions": [
{ "type": "issue_priority_greater_or_equal", "comparison": 75, "conditionResult": true },
{ "type": "event_frequency_count", "comparison": {"value": 50, "interval": "1hr"}, "conditionResult": true }
],
"actions": [{
"type": "email",
"integrationId": null,
"data": {},
"config": {
"targetType": "user",
"targetIdentifier": "<user_id>",
"targetDisplay": null
},
"status": "active"
}]
}]
}frequency051030601807201440Structure note: is always — actions live inside
.
triggers.actions[]actionFilters[].actionsjson
{
"name": "<Alert Name>",
"enabled": true,
"environment": null,
"config": { "frequency": 30 },
"triggers": {
"logicType": "any-short",
"conditions": [
{ "type": "first_seen_event", "comparison": true, "conditionResult": true }
],
"actions": []
},
"actionFilters": [{
"logicType": "all",
"conditions": [
{ "type": "issue_priority_greater_or_equal", "comparison": 75, "conditionResult": true },
{ "type": "event_frequency_count", "comparison": {"value": 50, "interval": "1hr"}, "conditionResult": true }
],
"actions": [{
"type": "email",
"integrationId": null,
"data": {},
"config": {
"targetType": "user",
"targetIdentifier": "<user_id>",
"targetDisplay": null
},
"status": "active"
}]
}]
}frequency051030601807201440结构说明: 始终为 ——actions 位于
中。
triggers.actions[]actionFilters[].actionsPhase 4: Create the Alert
阶段 4:创建告警
bash
curl -s -w "\n%{http_code}" -X POST \
"https://{region}.sentry.io/api/0/organizations/{org}/workflows/" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{payload}'Expect HTTP . The response contains the workflow .
201idbash
curl -s -w "\n%{http_code}" -X POST \
"https://{region}.sentry.io/api/0/organizations/{org}/workflows/" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{payload}'预期返回 HTTP 。响应中包含 workflow 。
201idPhase 5: Verify
阶段 5:验证
Confirm the alert was created and provide the UI link:
https://{org_slug}.sentry.io/monitors/alerts/{workflow_id}/If the org lacks the feature flag, the alert appears at:
workflow-engine-uihttps://{org_slug}.sentry.io/alerts/rules/确认告警已创建,并提供 UI 链接:
https://{org_slug}.sentry.io/monitors/alerts/{workflow_id}/如果 org 没有 feature flag,告警将显示在:
workflow-engine-uihttps://{org_slug}.sentry.io/alerts/rules/Managing Alerts
管理告警
bash
undefinedbash
undefinedList all workflows
List all workflows
curl -s "$API/workflows/" -H "$AUTH"
curl -s "$API/workflows/" -H "$AUTH"
Get one workflow
Get one workflow
curl -s "$API/workflows/{id}/" -H "$AUTH"
curl -s "$API/workflows/{id}/" -H "$AUTH"
Update a workflow
Update a workflow
curl -s -X PUT "$API/workflows/{id}/" -H "$AUTH" -H "Content-Type: application/json" -d '{payload}'
curl -s -X PUT "$API/workflows/{id}/" -H "$AUTH" -H "Content-Type: application/json" -d '{payload}'
Delete a workflow
Delete a workflow
curl -s -X DELETE "$API/workflows/{id}/" -H "$AUTH"
curl -s -X DELETE "$API/workflows/{id}/" -H "$AUTH"
Expect 204
Expect 204
undefinedundefinedTroubleshooting
故障排查
| Issue | Solution |
|---|---|
| 401 Unauthorized | Token needs |
| 403 Forbidden | Token must belong to the target org |
| 404 Not Found | Check org slug and region ( |
| 400 Bad Request | Validate payload JSON structure, check required fields |
| User ID not found | Verify email matches a member of the org |
| 问题 | 解决方案 |
|---|---|
| 401 Unauthorized | Token 需要具备 |
| 403 Forbidden | Token 必须属于目标 org |
| 404 Not Found | 检查 org slug 和 region( |
| 400 Bad Request | 校验 payload JSON 结构并检查必填字段 |
| 未找到用户 ID | 验证电子邮件是否与 org 成员匹配 |