新增告警抑制规则
功能介绍
该接口用于新增告警抑制规则。
调用方法
请参见如何调用API。
URI
POST /v2/{project_id}/alert/inhibit-rules
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,可以从控制台获取,也可以从调用API处获取。获取方式请参见:获取项目ID。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
从IAM服务获取的用户Token。获取方式请参见:获取Token。 |
Content-Type |
是 |
String |
消息体的类型(格式)。指定类型为“application/json”。 |
Enterprise-Project-Id |
否 |
String |
企业项目id。
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
告警抑制规则的名称。 只能由大小写字母、数字、下划线组成,且不能以下划线开头和结尾,最多不能超过100个字符。 |
desc |
否 |
String |
告警抑制规则描述。规则描述长度最大 1024。 |
match_v3 |
否 |
InhibitMatchV3Tag object |
告警抑制规则编排详情。(如果创建新版告警抑制规则,该参数必填,如果创建告警抑制规则,该参数为空) |
binding_group_rule |
否 |
String |
告警抑制规则绑定的告警分组规则名称。(如果创建新版告警抑制规则,该参数需关注,如果创建告警抑制规则,该参数为空) |
source_match |
否 |
Array<Array<InhibitMatchTag>> |
根源告警。(如果创建新版告警抑制规则,该参数为空,如果创建告警抑制规则,该参数必填) 根源告警最多可设置10个并行条件,每个并行条件下最多可设置10个串行条件。 |
target_match |
否 |
Array<Array<InhibitMatchTag>> |
抑制告警。(如果创建新版告警抑制规则,该参数为空,如果创建告警抑制规则,该参数必填) 抑制告警最多可设置10个并行条件,每个并行条件下最多可设置10个串行条件。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
nodes |
是 |
Array of InhibitRuleNode objects |
节点详情列表。 |
edges |
是 |
Array of Edge objects |
边详情列表。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
id |
是 |
String |
节点id。命名规范为:flow-“8位随机字符串”。 随机字符串只能由字母、数字、下划线和中划线组成。 例如:flow-M3pfK020 |
type |
是 |
String |
节点类型。 Start:开始节点。 End:结束节点。 Card:卡片节点。 |
businessType |
否 |
String |
卡片类型。(当type为Card时,该参数必填)
|
value |
否 |
InhibitConditionSubNode object |
告警抑制规则节点详情。(当type为Card时,该参数必填) |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
nodes |
否 |
Array of InhibitConditionSubNode objects |
子节点列表。 |
id |
是 |
String |
节点id。命名规范为:{businessType}-“8位随机字符串”。 随机字符串只能由字母、数字、下划线和中划线组成 例如:InhibitSourceCondition-M3pfK020 |
type |
是 |
String |
节点类型:
|
value |
否 |
String |
节点之间关系:
|
match |
否 |
InhibitMatchTag object |
路由规则匹配条件列表。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
key |
是 |
String |
告警抑制规则下根源告警或抑制告警key取值范围:
|
value |
是 |
Array of strings |
告警抑制规则下根源告警或抑制告警value取值范围。当表达式为正则时,value的长度不能超过256
|
operate |
是 |
String |
操作符:
|
响应参数
状态码: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/inhibit-rules { "desc" : "·123", "match_v3" : { "edges" : [ { "id" : "edge-M3pfK202", "source" : "flow-VHSvKyYY", "target" : "flow-ufs5Zsn3" }, { "id" : "edge-OrwQoSVg", "source" : "flow-ufs5Zsn3", "target" : "flow-eAheOiH5", "value" : "true" }, { "id" : "edge-ukREdGnr", "source" : "flow-ufs5Zsn3", "target" : "flow-f6P36v4a", "value" : "false" } ], "nodes" : [ { "id" : "flow-VHSvKyYY", "type" : "Start" }, { "businessType" : "InhibitSourceCondition", "id" : "flow-ufs5Zsn3", "type" : "Card", "value" : { "id" : "InhibitSourceCondition-wtJBNJD7", "nodes" : [ { "id" : "InhibitSourceCondition-awPpHgHv", "match" : { "key" : "resource_type", "operate" : "EQUALS", "value" : [ "service" ] }, "type" : "text" }, { "id" : "InhibitSourceCondition-DmfXe2vN", "match" : { "key" : "resource_type", "operate" : "EQUALS", "value" : [ "service" ] }, "type" : "text" }, { "id" : "InhibitSourceCondition-0fnYAVWg", "nodes" : [ { "id" : "InhibitSourceCondition-Xn7CUof5", "match" : { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] }, "type" : "text" } ], "type" : "bool", "value" : "and" }, { "id" : "InhibitSourceCondition-juUOsA2L", "match" : { "key" : "resource_provider", "operate" : "EQUALS", "value" : [ "1" ] }, "type" : "text" }, { "id" : "InhibitSourceCondition-JvtIwdL6", "match" : { "key" : "1", "operate" : "EQUALS", "value" : [ "1" ] }, "type" : "text" } ], "type" : "bool", "value" : "and" } }, { "businessType" : "InhibitTargetCondition", "id" : "flow-eAheOiH5", "type" : "Card", "value" : { "id" : "InhibitSourceCondition--foPmJou", "nodes" : [ { "id" : "InhibitSourceCondition--m9jJEAN", "match" : { "key" : "resource_type", "operate" : "EQUALS", "value" : [ "service" ] }, "type" : "text" }, { "id" : "InhibitSourceCondition-MmTv1BZ5", "match" : { "key" : "resource_provider", "operate" : "EQUALS", "value" : [ "1" ] }, "type" : "text" }, { "id" : "InhibitSourceCondition-7oz9ddLB", "nodes" : [ { "id" : "InhibitSourceCondition-oM73YTRG", "match" : { "key" : "2", "operate" : "EQUALS", "value" : [ "2" ] }, "type" : "text" } ], "type" : "bool", "value" : "and" } ], "type" : "bool", "value" : "and" } }, { "id" : "flow-f6P36v4a", "type" : "End" } ] }, "name" : "123" }
-
新增告警抑制规则
https://{Endpoint}/v2/{project_id}/alert/inhibit-rules { "desc" : "", "name" : "test", "source_match" : [ [ { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Critical" ] } ] ], "target_match" : [ [ { "key" : "event_severity", "operate" : "EQUALS", "value" : [ "Info" ] } ] ] }
响应示例
状态码:400
BadRequest 非法请求。建议直接修改该请求,不要重试该请求。
{
"error_code" : "AOM.08006001",
"error_msg" : "the inhibitName is exist",
"error_type" : "PARAM_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 请求被拒绝访问。返回该状态码,表明请求能够到达服务端,且服务端能够理解用户请求,但是拒绝做更多的事情,因为该请求被设置为拒绝访问,建议直接修改该请求,不要重试该请求。 |
错误码
请参见错误码。