自定義事件告警規則:創建
更新時間 2024-09-25 16:20:50
最近更新時間: 2024-09-25 16:20:50
分享文章
告警規則
自定義事件告警規則:創建
接口功能介紹
創建一個自定義事件的告警規則。
接口約束
regionID(資源池)存在且支持自定義事件監控產品,具體范圍見請求參數說明。
URI
POST /v4/monitor/create-custom-event-alarm-rule
路徑參數
無
Query參數
無
請求參數
請求頭header參數
無
請求體body參數
| 參數 | 是否必填 | 參數類型 | 說明 | 示例 | 下級對象 |
|---|---|---|---|---|---|
| regionID | 是 | String | ctyun資源池ID | 81f7728662dd11ec810800155d307d5b | |
| name | 是 | String | 規則名 | 自定義告警規則測試 | |
| desc | 否 | String | 描述 | test | |
| repeatTimes | 否 | Integer | 重復告警通知次數,默認為0 | 0 | |
| silenceTime | 否 | Integer | 告警接收策略靜默時間,多久重復通知一次,單位為秒 | 300 | |
| recoverNotify | 否 | Integer | 本參數表示恢復是否通知。默認值0。取值范圍:0:否。1:是。根據以上范圍取值。 | 0 | |
| notifyType | 否 | Array of Strings | 本參數表示告警接收策略。取值范圍:email:郵件告警。sms:短信告警。根據以上范圍取值。 | ['email','sms'] | |
| contactGroupList | 否 | Array of Strings | 告警聯系人組 | ['000f0322-1f4d-8cc8-bb2e-1c30fb751ccc'] | |
| notifyWeekdays | 否 | Array of Integers | 本參數表示通知周期。默認值[0,1,2,3,4,5,6]。取值范圍:0:周日。1:周一。2:周二。3:周三。4:周四。5:周五。6:周六。根據以上范圍取值。 | [0,1,2,3,4,5,6] | |
| notifyStart | 否 | String | 通知起始時段,默認為00:00:00 | 00:00:00 | |
| notifyEnd | 否 | String | 通知結束時段,默認為23:59:59 | 23:59:59 | |
| webhookUrl | 否 | Array of Strings | 告警狀態變更webhook推送地址 | ['//www.daliqc.cn/'] | |
| customEventID | 是 | String | 自定義事件ID | EVENT63cb8954325480a320230707180 | |
| value | 是 | String | 出現次數,告警閾值,整數格式字符串 | 1 | |
| period | 是 | String | 本參數表示算法統計周期。參數fun為last時可不傳。本參數格式為“數字+單位”。最大周期為24小時。單位取值范圍:m:分鐘。h:小時。根據以上范圍取值。 | 5m |
響應參數
| 參數 | 參數類型 | 說明 | 示例 | 下級對象 |
|---|---|---|---|---|
| statusCode | Integer | 返回狀態碼(800為成功,900為失敗),默認值:800 | 800 | |
| errorCode | String | 失敗時的錯誤代碼,參見公共錯誤碼說明 | ||
| message | String | 失敗時的錯誤描述,一般為英文描述 | Success | |
| msgDesc | String | 失敗時的錯誤描述,一般為中文描述 | 成功 | |
| error | String | 錯誤碼,請求成功時,不返回該字段 | Openapi.Parameter.Error | |
| returnObj | Object | 返回對象 | returnObj |
表 returnObj
| 參數 | 參數類型 | 說明 | 示例 | 下級對象 |
|---|---|---|---|---|
| alarmRuleID | String | 告警規則ID | '83bd7537-9e06-5a45-a3b5-f4b13a7e81ea' |
請求示例
請求url
/v4/monitor/create-custom-event-alarm-rule
請求頭header
無
請求體body
{
"regionID": "81f7728662dd11ec810800155d307d5b",
"name": "自定義告警規則測試",
"desc": "test",
"repeatTimes": 0,
"silenceTime": 300,
"recoverNotify": 0,
"notifyType": ["email"],
"contactGroupList": ["000f0322-1f4d-8cc8-bb2e-1c30fb751ccc"],
"notifyWeekdays": [0, 1, 2, 3, 4, 5, 6],
"notifyStart": "00:00:00",
"notifyEnd": "23:59:59",
"webhookUrl": ["//www.daliqc.cn/"],
"customEventID": "Event63cb8954325480a320230707180",
"value": "3",
"period": "5m"
}
響應示例
{
"statusCode": 800,
"returnObj": {
"alarmRuleID": "83bd7537-9e06-5a45-a3b5-f4b13a7e81ea"
},
"errorCode": "",
"message": "Success",
"msgDesc":"成功"
}
狀態碼
| 狀態碼 | 描述 |
|---|---|
| 200 | 表示請求成功 |
錯誤碼
| 錯誤碼 | 描述 |
|---|---|
| Monitor.CustomAlarmRule.ContactGroupNotFound | 告警聯系組不存在 |
| Monitor.CustomAlarmRule.CustomEventNotFound | 自定義事件不存在 |
| 其他 | 參見公共錯誤碼說明 |