跳转至

REST API 集成

睿象云Cloud Alert提供 2 种通用方式集成您的告警:API 集成、邮箱集成Webhook集成


API 集成 CA 步骤

  1. 创建应用

在 CA 界面创建 API 应用,并获取 appkey

  1. 在第三方工具/自行开发的监控工具中调用 API 推送告警到 Cloud Alert

API 相关参数及示例参考下方:接口、参数列表、告警示例等。


接口

说明
接口(http) http://api.aiops.com/alert/api/event
接口 (https) https://caweb.aiops.com/alert/api/event/
调用方法 POST
参数格式(body) { "app": "--", "eventId": "12345", "eventType": "trigger", "alarmName": "FAILURE for production/HTTP on machine 192.168.0.253", "entityName": "host-192.168.0.253", "entityId": "host-192.168.0.253", "priority": 1, "alarmContent": { "ping time": "2500ms", "load avg": 0.75 }, "details": { "details":"haha" }, "contexts": [ { "type": "link", "text": "generatorURL", "href": "http://www.baidu.com" }, { "type": "link", "href": "http://www.sina.com", "text": "CPU Alerting" }, { "type": "image", "src": "http://www.baidu.com/a.png" }] }
参数格式(url) ?app=--&eventId=xxx&eventType=trigger&alarmName=xxx&priority=2

提示

参数格式中,"app":"--" --处填入您新建应用时生成的appkey


参数列表

参数 类型 必填 备注信息
app string 必填 告警集成的应用 KEY
eventType string 必填 触发告警 trigger,解决告警 resolve
eventId string 必填 外部事件 id,告警压缩和关闭时用到。超长(250)会做md5加密处理
alarmName string 可选 告警标题,建议不为空
alarmContent string 必填 告警详情,最大长度 800 个字符
entityName string 可选 告警对象名,如具体主机或数据库
entityId string 可选 告警对象 id
priority int 可选 告警级别;提醒 1,警告 2,严重 3,通知 4,致命 5
host string 可选 主机
service string 可选 服务
details json 可选 详情
contexts json 可选 上下文

提示

参数必须进行encode。


输出参数

参考公用参数


告警示例

URL 参数方式

POST http://api.aiops.com/alert/api/event?app=--&eventType=trigger&alarmName=主机192.168.0.232
CPU使用率过高&eventId=21946515-9eb2-4078-813f-a8420baf0dab-7&alarmContent=主机cpu使用率90%,
请持续观察,30分钟内没有降下来需要重点关注&entityName=HostY192.168.0.100&entityId=123456&priority=3

POST body 方式

输入

curl -H "Content-type: application/json" -X POST     -d '{
 "app": "--", #--处填入您新建应用时生成的appkey 
 "eventId": "12345",
 "eventType": "trigger",
 "alarmName": "FAILURE for production/HTTP on machine 192.168.0.253",
 "entityName": "hadoop001/HTTP",
 "entityId": "host-192.168.0.253",
 "priority": 3,
 "host": "hadoop001",
 "service": "network",
 "alarmContent": {
     "ping time": "1500ms",
     "load avg": 0.75
 },
 details: {
     "details":"haha"
 },
 contexts: [
 {
     "type": "link",
     "text": "generatorURL",
     "href": "http://www.baidu.com"
 },
 {
     "type": "link",
     "href": "http://www.sina.com",
     "text": "CPU Alerting"
 },
 {
     "type": "image",
     "src": "https://aiops.com/images/logo2.png"
 }]
}'     "http://api.aiops.com/alert/api/event"

输出

{
     "result": "success",
     "message": "receive event success",
     "data": 0,
     "totalCount": 0,
     "code": "200"
}

API告警与 CA 告警级别映射关系

睿象云 rest-api(priority)
致命 5
严重 3
警告 2
提醒 1
通知 4
睿象云 rest-api
事件ID (eventId) eventId