> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 试一试路由

> 算出带一组标签的事件会分派给哪个团队、走哪条升级策略。

```http theme={null}
POST /api/v1/alerts/routing/test
```

按现在的路由规则、团队的值班策略和服务目录，算出一个带这些标签的事件会怎么[分派](https://docs.molesignal.com/zh-Hans/alerting/routing.md#分派顺序)，需要 `alerts.routing.read`。按来源用默认策略计算，不开事件，也不发通知。

| 字段 | 类型 | 说明 |
| - | - | - |
| `labels` | object | 事件的标签。来源按标签 `alert.source` 认：`external` 是告警来源，`synthetic` 是拨测检查，其他是告警规则。 |
| `services` | array | 受影响的服务，标签里没有 `service.name` 和 `service` 时取第一个。 |
| `severity` | string | `info`、`warning`（默认）、`error` 或 `critical`。 |

```bash cURL theme={null}
curl -X POST http://localhost:5080/api/v1/alerts/routing/test \
  -H "authorization: Bearer $MS_TOKEN" \
  -H "content-type: application/json" \
  -d '{"labels": {"service.name": "checkout", "env": "prod"}, "severity": "critical"}'
```

```json 200 theme={null}
{
  "decision": {
    "escalation_policy_id": "<policy-id>",
    "team_id": "<team-id>",
    "routing": { "reason": "rule", "rule_id": "<rule-id>", "rule_name": "Payments in production" }
  },
  "matched_rule_id": "<rule-id>",
  "service": "default/checkout",
  "service_team_id": "<team-id>",
  "label_team_id": null
}
```

| 字段 | 说明 |
| - | - |
| `decision.escalation_policy_id` | 事件会走的升级策略；`default` 表示默认策略。 |
| `decision.team_id` | 事件会分派到的团队，没有时为 `null`。 |
| `decision.routing` | 分派的依据，与事件上的 `routing` 相同，见[事件字段](https://docs.molesignal.com/zh-Hans/api/alerting/list-incidents.md#事件字段)。 |
| `matched_rule_id` | 命中的路由规则，没有时为 `null`。 |
| `service` | 用来查负责团队的服务，写成 `命名空间/服务名`。 |
| `service_team_id` | 服务目录中这个服务的负责团队。 |
| `label_team_id` | 标签 `team_id` 或 `team` 指向的团队。 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.