> ## 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}
GET /api/v1/alerts/insights
```

汇总窗口内创建的事件。该调用需要 `alerts.read`。

**查询参数**

| 参数 | 类型 | 说明 |
| - | - | - |
| `window_secs` | integer | 回看窗口，单位为秒。默认 `604800`（7 天）。取值限制在 3600 到 31536000 之间。 |

```bash cURL theme={null}
curl "http://localhost:5080/api/v1/alerts/insights?window_secs=86400" \
  -H "authorization: Bearer $MS_JWT"
```

```json 200 theme={null}
{
  "window_secs": 86400,
  "total": 5,
  "active": 1,
  "closed": 4,
  "mttr_secs": 59.34,
  "noise_rate": 0.5,
  "by_hour": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  "by_severity": { "critical": 2, "error": 3 },
  "top_services": [{ "key": "checkout", "count": 3 }],
  "top_rules": [
    { "key": "3KEDBLvTYO6DnWi8H9S9MNLpPT7", "count": 3 },
    { "key": "3KEDviJWhe5wIf6gnQyS8kucGhJ", "count": 2 }
  ]
}
```

**响应**

| 字段 | 说明 |
| - | - |
| `window_secs` | 限制范围之后的窗口。 |
| `total` | 窗口内创建的事件数量。 |
| `active` | 状态为 `open` 或 `acknowledged` 的事件。 |
| `closed` | 状态为 `resolved` 或 `closed` 的事件。 |
| `mttr_secs` | 已解决事件从创建到解决的平均秒数。没有已解决事件时为 `0`。 |
| `noise_rate` | 在 60 秒内被解决的已解决事件所占的比例，范围为 0 到 1。没有已解决事件时为 `0`。 |
| `by_hour` | 按创建时刻的 UTC 小时统计的 24 个事件数量。 |
| `by_severity` | 各严重程度的数量。没有事件的严重程度不会出现。 |
| `top_services`、`top_rules` | 最多 8 个 `key` 与 `count` 条目，数量高者在前。键是服务名称或规则标识符。 |


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