新增告警分组规则
功能介绍
该接口用于新增告警分组规则。
调用方法
请参见如何调用API。
URI
POST /v2/{project_id}/alert/group-rules
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,可以从控制台获取,也可以从调用API处获取。获取方式请参见:获取项目ID。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
从IAM服务获取的用户Token。获取方式请参见:获取Token。 |
Content-Type |
是 |
String |
消息体的类型(格式)。指定类型为“application/json”。 |
Enterprise-Project-Id |
否 |
String |
企业项目id。获取方式请参见:获取企业项目ID 。
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
告警分组规则名称。 只能由大小写字母、数字、下划线组成,且不能以下划线开头和结尾,最多不能超过100个字符。 |
desc |
否 |
String |
告警分组规则的描述。最多不能超过1024个字符。 |
match_v3 |
否 |
GroupV3Tag object |
告警分组编排详情。(如果创建新版告警分组规则,该参数必填,如果创建告警分组规则,该参数为空) |
detail |
否 |
Array of GroupRuleDetail objects |
告警分组规则的分组条件列表。(如果创建新版告警分组规则,该参数为空,如果创建告警分组规则,该参数必填) 分组条件最多可设置10个并行条件,每个并行条件下最多可设置10个串行条件,每个并行条件下可设置一个或多个AOM告警通知规则。 |
group_by |
否 |
Array of strings |
通知合并规则。(如果创建新版告警分组规则,该参数为空,如果创建告警分组规则,该参数必填)
目前仅支持如下通知规则组合: 1.按告警源 ["resource_provider"] 2.按告警源+严重度 ["resource_provider","event_severity"] 3.按告警源+所有标签 ["resource_provider","分组条件里的标签名","event_severity","resource_type"] |
group_wait |
否 |
Integer |
首次等待时间。(如果创建新版告警分组规则,该参数为空,如果创建告警分组规则,该参数必填) 取值范围为0s-10min 单位为秒,分钟需转为秒,当为1min时,需填写60s |
group_interval |
否 |
Integer |
变化等待时间。(如果创建新版告警分组规则,该参数为空,如果创建告警分组规则,该参数必填) 取值范围为5s-30min,分钟需转为秒,当为1min时,需填写60s |
group_repeat_waiting |
否 |
String |
重复等待。(如果创建新版告警分组规则,该参数为空,如果创建告警分组规则,该参数必填) 取值范围为0min-15day,分钟需转为秒,当为1min时,需填写60s。 |
ai_group_by |
否 |
String |
智能通知合并规则。智能合并模式开关功能当前仅在华北-北京四,华南-广州区域开放。系统默认关闭智能合并模式开关,打开开关后,用户可以按照选择的告警属性智能合并告警。 数组为空时,表示不开启智能通知合并。
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
nodes |
是 |
Array of GroupConditionNode objects |
节点详情列表。 必须包含开始节点,结束节点,card节点。 |
edges |
是 |
Array of Edge objects |
边详情列表。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
id |
是 |
String |
节点id。命名规范为:flow-“8为随机字符串”。 随机字符串只能由字母、数字、下划线和中划线组成。 例如:flow-lvzgw9Td |
type |
否 |
String |
节点类型。
|
businessType |
否 |
String |
业务类型。(当nodeType为Card时,该参数必填)
|
value |
否 |
GroupConditionSubNode object |
告警分组规则节点详情。(当nodeType为Card时,该参数必填) |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
nodes |
否 |
Array of GroupConditionSubNode objects |
子节点列表。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空) |
id |
是 |
String |
节点id。命名规范:{businessType}-"8位随机字符串"。 随机字符串只能由字母、数字、下划线和中划线组成 例如:GroupCondition-Lh0dTxyd |
type |
否 |
String |
节点类型。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空)
|
value |
否 |
String |
节点之间关系。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空)
|
match |
否 |
MatchTag object |
路由规则匹配条件列表。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空) |
combineConfig |
否 |
CombineConfig object |
通知合并节点详情。(当businessType为GroupCondition时,该参数为空,当businessType为CombineConf,该参数为必填) |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
key |
是 |
String |
分组条件key取值范围:
|
value |
是 |
Array of strings |
分组条件value取值范围。当表达式为正则时,value的长度不能超过256
|
operate |
是 |
String |
操作符:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
group_by |
否 |
Array of strings |
通知合并规则。
目前仅支持如下通知规则组合: 1.按告警源 ["resource_provider"] 2.按告警源+严重度 ["resource_provider","event_severity"] 3.按告警源+所有标签 ["resource_provider","tag","event_severity","resource_type"] |
ai_group_by |
否 |
String |
智能通知合并规则。 数组为空时,表示不开启智能通知合并。
|
group_wait |
是 |
Integer |
首次等待时间,取值范围为0s-10min 单位为秒,分钟需转为秒,当为1min时,需填写60s。 |
group_interval |
是 |
Integer |
变化等待时间,取值范围为5s-30min,分钟需转为秒,当为1min时,需填写60s。 |
group_repeat_waiting |
是 |
Integer |
重复等待,取值范围为0min-15day,分钟需转为秒,当为1min时,需填写60s。 |
bind_notification_rule_ids |
是 |
Array of strings |
绑定告警行动规则名称列表。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
id |
是 |
String |
边id。命名规范为:edge-"8位随机字符串”。 随机字符串只能由字母、数字、下划线和中划线组成。 例如:edge-M3pfK202 |
source |
是 |
String |
边起始节点id。取值于nodes列表里的id。 |
target |
是 |
String |
边终止节点id。取值于nodes列表里的id。 |
value |
否 |
String |
边value。节点之间的关系true或false。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
match |
是 |
Array of MatchTag objects |
路由规则匹配条件列表。 |
bind_notification_rule_ids |
是 |
Array of strings |
绑定的告警通知规则名称。 |
响应参数
状态码:204
No Content 表示请求成功,但没有内容返回。
状态码:400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 最小长度:12 最大长度:12 |
error_msg |
String |
错误信息。 最小长度:0 最大长度:1024 |
error_type |
String |
错误类型。 最小长度:0 最大长度:128 |
trace_id |
String |
请求id。 最小长度:32 最大长度:32 |
状态码:403
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 最小长度:12 最大长度:12 |
error_msg |
String |
错误信息。 最小长度:0 最大长度:1024 |
error_type |
String |
错误类型。 最小长度:0 最大长度:128 |
trace_id |
String |
请求id。 最小长度:32 最大长度:32 |
请求示例
-
新增新版告警分组规则
https://{Endpoint}/v2/{project_id}/alert/group-rules { "match_v3" : { "edges" : [ { "id" : "edge-gMPwWev2", "source" : "flow-lKSGbvq-", "target" : "flow-1JBeHxLU" }, { "id" : "edge-CkdHb85Z", "source" : "flow-1JBeHxLU", "target" : "flow-y7b5HNsE", "value" : "true" }, { "id" : "edge-BAurs1Qu", "source" : "flow-1JBeHxLU", "target" : "flow-_p6cFvLk", "value" : "false" }, { "id" : "edge-wsVSHYce", "source" : "flow-_p6cFvLk", "target" : "flow-xc0QfFsN", "value" : "true" }, { "id" : "edge-qOQTDuu9", "source" : "flow-_p6cFvLk", "target" : "flow-lvZgW9Td", "value" : "false" }, { "id" : "edge-Lh_ODRAX", "source" : "flow-lvZgW9Td", "target" : "flow-oUm2Cw50", "value" : "true" }, { "id" : "edge-SPhMFJXM", "source" : "flow-lvZgW9Td", "target" : "flow-AlJfG3vo", "value" : "false" }, { "id" : "edge-V50dBRsx", "source" : "flow-AlJfG3vo", "target" : "flow-cFpXzlxZ" } ], "nodes" : [ { "id" : "flow-lKSGbvq-", "type" : "Start" }, { "businessType" : "GroupCondition", "id" : "flow-1JBeHxLU", "type" : "Card", "value" : { "id" : "GroupCondition-Ive7unRq", "nodes" : [ { "id" : "GroupCondition-PsYsjYeE", "match" : { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] }, "type" : "text" }, { "id" : "GroupCondition-BG9Q_fFo", "nodes" : [ { "id" : "GroupCondition-Tb6XLa3x", "match" : { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] }, "type" : "text" } ], "type" : "bool", "value" : "and" }, { "id" : "GroupCondition-uLkAf9Ze", "match" : { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] }, "type" : "text" }, { "id" : "GroupCondition-_rgpgeeu", "nodes" : [ { "id" : "GroupCondition-lCOy7A4X", "match" : { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] }, "type" : "text" } ], "type" : "bool", "value" : "or" }, { "id" : "GroupCondition-1xrYkISG", "match" : { "key" : "resource_provider", "operate" : "EQUALS", "value" : [ "1" ] }, "type" : "text" }, { "id" : "GroupCondition-7aQDn88G", "match" : { "key" : "1", "operate" : "EQUALS", "value" : [ "1" ] }, "type" : "text" } ], "type" : "bool", "value" : "and" } }, { "businessType" : "CombineConf", "id" : "flow-y7b5HNsE", "type" : "Card", "value" : { "combineConfig" : { "ai_group_by" : [ "event_name", "alarm_info", "tag" ], "bind_notification_rule_ids" : [ "aaa" ], "group_interval" : 5, "group_repeat_waiting" : 0, "group_wait" : 0 }, "id" : "CombineConf-v1ga6Xoq" } }, { "businessType" : "GroupCondition", "id" : "flow-_p6cFvLk", "type" : "Card", "value" : { "id" : "GroupCondition-Jp6ukhnf", "nodes" : [ { "id" : "GroupCondition-o2wukru4", "match" : { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] }, "type" : "text" } ], "type" : "bool", "value" : "and" } }, { "businessType" : "CombineConf", "id" : "flow-xc0QfFsN", "type" : "Card", "value" : { "combineConfig" : { "bind_notification_rule_ids" : [ "LTQTEST-ASASDASDDSA" ], "group_by" : [ "resource_provider" ], "group_interval" : 5, "group_repeat_waiting" : 0, "group_wait" : 0 }, "id" : "CombineConf-zlsIhUa1" } }, { "businessType" : "GroupCondition", "id" : "flow-lvZgW9Td", "type" : "Card", "value" : { "id" : "GroupCondition-c-HEgnga", "nodes" : [ { "id" : "GroupCondition-6PXrURL7", "match" : { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] }, "type" : "text" }, { "id" : "GroupCondition-7i3Zw2ad", "match" : { "key" : "1", "operate" : "EQUALS", "value" : [ "1" ] }, "type" : "text" }, { "id" : "GroupCondition-cQz1fQu2", "match" : { "key" : "resource_provider", "operate" : "EQUALS", "value" : [ "1" ] }, "type" : "text" } ], "type" : "bool", "value" : "and" } }, { "businessType" : "CombineConf", "id" : "flow-oUm2Cw50", "type" : "Card", "value" : { "combineConfig" : { "bind_notification_rule_ids" : [ "LTQTEST-ASASDASDDSA" ], "group_by" : [ "resource_provider" ], "group_interval" : 5, "group_repeat_waiting" : 0, "group_wait" : 0 }, "id" : "CombineConf-exvbZXma" } }, { "businessType" : "CombineConf", "id" : "flow-AlJfG3vo", "type" : "Card", "value" : { "combineConfig" : { "bind_notification_rule_ids" : [ "aaa" ], "group_by" : [ "resource_provider" ], "group_interval" : 5, "group_repeat_waiting" : 0, "group_wait" : 0 }, "id" : "CombineConf-oQJVcE1q" } }, { "id" : "flow-cFpXzlxZ", "type" : "End" } ] }, "name" : "aomtest" }
-
新增告警分组规则(开启智能合并模式开关)
https://{Endpoint}/v2/{project_id}/alert/group-rules { "ai_group_by" : [ "event_name" ], "desc" : "", "detail" : [ { "bind_notification_rule_ids" : [ "testyq2" ], "match" : [ { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] } ] } ], "group_by" : [ "resource_provider" ], "group_interval" : 5, "group_repeat_waiting" : 60, "group_wait" : 0, "name" : "aomtest" }
-
新增告警分组规则(关闭智能合并模式开关)
https://{Endpoint}/v2/{project_id}/alert/group-rules { "ai_group_by" : [ ], "desc" : "", "detail" : [ { "bind_notification_rule_ids" : [ "testyq2" ], "match" : [ { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] } ] } ], "group_by" : [ "resource_provider" ], "group_interval" : 5, "group_repeat_waiting" : 60, "group_wait" : 0, "name" : "aomtest" }
响应示例
状态码:400
BadRequest 非法请求。建议直接修改该请求,不要重试该请求。
{
"error_code" : "AOM.08001001",
"error_msg" : "grouping name is invalid!",
"trace_id" : ""
}
状态码:403
Forbidden 请求被拒绝访问。返回该状态码,表明请求能够到达服务端,且服务端能够理解用户请求,但是拒绝做更多的事情,因为该请求被设置为拒绝访问,建议直接修改该请求,不要重试该请求。
{
"error_code" : "AOM.0403",
"error_msg" : "auth failed.",
"error_type" : "AUTH_FAILED",
"trace_id" : null
}
状态码
状态码 |
描述 |
---|---|
204 |
No Content 表示请求成功,但没有内容返回。 |
400 |
BadRequest 非法请求。建议直接修改该请求,不要重试该请求。 |
403 |
Forbidden 请求被拒绝访问。返回该状态码,表明请求能够到达服务端,且服务端能够理解用户请求,但是拒绝做更多的事情,因为该请求被设置为拒绝访问,建议直接修改该请求,不要重试该请求。 |
错误码
请参见错误码。