POST /api/v1/alerts/routing/rules
alerts.routing.manage。新规则排在最后,用调整顺序移到前面。一个组织最多 200 条路由规则。
| 字段 | 类型 | 说明 |
|---|---|---|
name | string | 必填,去掉首尾空白后 1 到 128 个字符。 |
enabled | boolean | 默认 true。 |
conditions | array | 最多 16 个条件,默认为空。key 为 1 到 512 个字符;equals、not_equals 和 matches 各带一个值,in 带 1 到 100 个值,每个值最多 512 个字符;matches 的正则要能编译。 |
min_severity | string | null | info、warning、error 或 critical,默认不限。 |
origins | array | rule、external、synthetic 中的若干个,默认为空,即不限。 |
target | object | 必填。{"kind": "team", "team_id": …} 须是本组织的团队,{"kind": "policy", "policy_id": …} 须是本组织的升级策略。 |
curl -X POST http://localhost:5080/api/v1/alerts/routing/rules \
-H "authorization: Bearer $MS_TOKEN" \
-H "content-type: application/json" \
-d '{"name": "Payments in production", "conditions": [{"key": "env", "operator": "equals", "values": ["prod"]}], "min_severity": "error", "target": {"kind": "team", "team_id": "<team-id>"}}'
| 状态码 | 原因 |
|---|---|
400 | 字段不对,例如名称为空、条件的取值个数不对、正则无法编译、去向的团队或策略不存在,或组织已有 200 条规则。 |
403 | Token 缺少 alerts.routing.manage。 |
422 | 缺少 name 或 target,或取值无法识别,例如未知的 operator。响应为纯文本。 |