版本 2.4.8 · 最新
告警记录 alerts
最近的告警与恢复记录,保留 30 天。
点击任一接口,右侧显示对应的调用示例。
节点调度鉴权: 仅管理员1 个接口
鉴权
请求头带 X-API-Key(在「API 密钥」页开通,密钥只在开通时显示一次);也可用登录得到的 Authorization: Bearer 令牌。
X-API-Key
鉴权失败回 401;无权回 403(code 为 insufficient_scope 等)。
约定
分页参数 page(从 1 起)、page_size;排序 sort=字段 或 -字段。
时间一律 RFC 3339(UTC);金额单位为分。
写操作成功回 200/201/204;重复提交按资源唯一键回 409。
GET
/api/v2/alerts列出最近告警与恢复记录
鉴权: 仅管理员
查询参数
| 字段 | 类型 | 说明 |
|---|---|---|
page | integer | 页码,从 1 开始。 |
page_size | integer | 每页条数。 |
rule | string | 按规则名过滤。 |
kind | AlertKind | 按种类过滤:fire 告警;resolve 恢复。 |
告警记录对象
| 字段 | 类型 | 说明 |
|---|---|---|
created_at | string | 创建时间 |
detail | string | 补充说明。 |
id | integer | 记录 ID |
kind | AlertKind | fire 告警;resolve 恢复。 |
msg_id | integer | 发出的通知(站内信 id)。 |
rule | string | 告警规则标识。 |
subject | string | 告警针对的对象,如节点或站点。 |
threshold | number | 规则的阈值。 |
title | string | 规则中文名(规则已不在表里时同 rule)。 |
unit | string | 数值与阈值的单位。 |
value | number | 触发告警的当前值。 |
返回与错误
成功直接回资源 JSON(HTTP 2xx);失败回 application/problem+json(code、detail,校验失败带 errors);列表为 items + total。
成功
{
"id": 1,
"name": "example"
}列表
{
"items": [
{
"id": 1
}
],
"page": 1,
"page_size": 20,
"total": 1
}失败
{
"code": "validation_failed",
"detail": "请求参数不合法",
"errors": [
{
"code": "required",
"field": "/name",
"message": "name 必填"
}
],
"request_id": "0123456789abcdef",
"status": 422,
"title": "Unprocessable Entity",
"type": "about:blank"
}