GET /api/v1/alerts/routing/rules
position 从小到大)列出组织的路由规则,需要 alerts.routing.read。停用的规则也在列表里。
curl http://localhost:5080/api/v1/alerts/routing/rules \
-H "authorization: Bearer $MS_TOKEN"
[
{
"id": "3KF0q7vXbJ2mYc8sTn4LwRk9Ez1",
"org_id": "<organization-id>",
"name": "Payments in production",
"enabled": true,
"position": 0,
"conditions": [
{ "key": "env", "operator": "equals", "values": ["prod"] },
{ "key": "service.name", "operator": "in", "values": ["checkout", "cart"] }
],
"min_severity": "error",
"origins": [],
"target": { "kind": "team", "team_id": "<team-id>" },
"created_by": "<user-id>",
"created_at": 1790000000000000,
"updated_at": 1790000000000000
}
]
规则字段
| 字段 | 说明 |
|---|---|
id、org_id | 规则与组织的标识符。 |
name | 规则名称。 |
enabled | 停用的规则不参与比对。 |
position | 比对顺序,小的先比。 |
conditions | 对事件标签的条件,全部满足才算命中;为空时匹配所有事件。每个条件有 key、operator 和 values。 |
min_severity | 事件严重度不低于它才命中:info、warning、error 或 critical;null 不限。 |
origins | 只对这些来源的事件生效:rule(告警规则)、external(告警来源)、synthetic(拨测检查);为空时不限。 |
target | 命中后的去向:{"kind": "team", "team_id": …} 或 {"kind": "policy", "policy_id": …}。 |
created_by | 创建规则的用户。 |
created_at、updated_at | 创建和最后修改的时间,单位为微秒。 |
operator 的取值:
operator | values | 命中 |
|---|---|---|
equals | 一个值 | 标签等于这个值。 |
not_equals | 一个值 | 标签不等于这个值,事件没有这个标签也算。 |
in | 一个或多个值 | 标签等于其中任何一个。 |
matches | 一个正则 | 整个标签值匹配这个正则。 |