功能介绍
告警状态页面接口调用说明。
URI
GET /apis/monitoring/v1/ecms/alerts
请求消息
参数 | 参数类型 | 是否必选 | 描述 | 默认值 | 可选值/示例 |
---|---|---|---|---|---|
status | String | 否 | 正则表达式,告警状态 | unresolved | unresolved 实时告警 resolved 已恢复告警 |
levels | String | 否 | 正则表达式,告警级别 | critical|warning|info 所有级别 |
critical 严重 warning 警告 info 信息 |
types | String | 否 | 正则表达式,告警类型 | service|storage|host|logging 所有类型 |
service 服务 storage 存储 host 主机 logging 日志 |
start | String | 否 | Unix时间格式,查询开始时间 | Now | 1559347200 |
end | String | 否 | Unix时间格式,查询结束时间 | 1561939200 |
说明:
- 以上均为可选参数,若不指定end,则默认查询触发时间在一个月内的实时告警;
- 正则表达式: string1|string2|… 如: critical|warning;
- status、levels、types均是由各自可选值任意组合成的正则表达式;
- start时间戳需小于end时间戳。
响应消息
参数 | 描述 |
---|---|
alerts_status | 告警状态 |
total | 告警总数 |
level_info | 告警级别统计信息,critical:严重级别数量、warning:警告级别数量、info:信息级别数量 |
type_info | 告警类型统计信息,service:服务类型数量、storage:存储类型数量、log:日志类型数量、host:主机类型数量 |
alerts_meta | 告警原始内容 |
results | 结果列表 |
示例
空值:
{ "alerts_status": "unresolved", "total": 0, "level_info": { "critical": 0, "warning": 0, "info": 0 }, "type_info": { "service": 0, "storage": 0, "log": 0, "host": 0 }, "alerts_meta": { "results": [] } }
异常返回:
{"error":"***"}
具体示例:查询告警触发时间在start和end之间,严重级别,服务和日志类型的已恢复告警
请求示例
curl -H 'X-Auth-Token: gAAAAABf5VKsaOPsOgziyXIPpX2vWnkSUnvgAPP9GlEzLGDo_BqcDqFpACNttXor7N4-AR7CMJVzgi0E3L54W4Y5RE2G8slwDfyll0g_sqmYQadZQOpn7C8709xRFgYQSozZKCufqF8LWu6xnRrm5mEUDdRyrlvi8w6aolUf85t1D5hXsnk3Emk' 'http://emla.openstack.svc.cluster.local/apis/monitoring/v1/ecms/alerts?status=resolved&levels=critical&types=service|logging&start=1612388700&end=1612393200'
响应示例
{ "alerts_status": "resolved", "total": 3, "level_info": { "critical": 3, "warning": 0, "info": 0 }, "type_info": { "service": 3, "storage": 0, "log": 0, "host": 0 }, "alerts_meta": { "results": [ { "startsAt": "2021-02-04T05:45:31.000000", "endsAt": "2021-02-04T06:20:10.000000", "status": "resolved", "labels": { "alert_id": "30040", "alertgroup": "service", "alertname": "【服务】集群时间同步服务停止服务", "company": "EasyStack", "effect_range": "others", "instance": "kube-state-metrics", "project": "EasyStack", "severity": "critical" }, "annotations": { "alertname_en": "[Service] The time synchronization service of cluster has stopped", "description": "集群时间同步服务停止服务,持续5分钟告警。", "description_en": "The time synchronization service of cluster has stopped, and this situation continues for 5 minutes.", "solution": "请联系您的软件服务提供商,进行问题排查。", "solution_en": "Please contact your software service provider for problem checking.", "summary": "集群时间同步服务停止服务。", "summary_en": "The time synchronization service of cluster has stopped." } }, { "startsAt": "2021-02-04T05:45:56.000000", "endsAt": "2021-02-04T05:48:39.000000", "status": "resolved", "labels": { "alert_id": "30051", "alertgroup": "service", "alertname": "【服务】云监控平台无法访问", "company": "EasyStack", "effect_range": "others", "instance": "http://grafana-dashboard.openstack.svc.cluster.local:3000/login/", "job": "blackbox-exporter", "project": "EasyStack", "severity": "critical" }, "annotations": { "alertname": "【服务】云监控平台无法访问", "alertname_en": "[Service] Cloud Monitor Service cannot be accessed", "description": "云监控平台无法访问,持续5分钟告警。", "description_en": "Cloud Monitor Service cannot be accessed, and this situation continues for 5 minutes.", "solution": "请联系您的软件服务提供商,进行问题排查。", "solution_en": "Please contact your software service provider for problem checking.", "summary": "云监控平台无法访问。", "summary_en": "Cloud Monitor Service cannot be accessed." } }, { "startsAt": "2021-02-04T06:27:31.000000", "endsAt": "2021-02-04T06:28:10.000000", "status": "resolved", "labels": { "alert_id": "30038", "alertgroup": "service", "alertname": "【服务】集群自动化中心服务停止服务", "company": "EasyStack", "effect_range": "others", "project": "EasyStack", "severity": "critical" }, "annotations": { "alertname_en": "[Service] The automation center service of cluster has stopped", "description": "集群自动化中心服务停止服务,持续5分钟告警。", "description_en": "The automation center of cluster has stopped, and this situation continues for 5 minutes.", "solution": "请联系您的软件服务提供商,进行问题排查。", "solution_en": "Please contact your software service provider for problem checking.", "summary": "集群自动化中心服务停止服务。", "summary_en": "The automation center service of cluster has stopped." } } ] } }
2021-02-04 05:45:00 ~ 2021-02-04 07:00:00这段时间触发的已恢复告警统计:
告警总数 严重 警告 信息 3 3 0 0 服务 存储 日志 主机 3 0 0 0