文档首页/ 应用运维管理 AOM/ API参考/ API/ 告警/ 更新告警分组规则
更新时间:2025-07-01 GMT+08:00
分享

更新告警分组规则

功能介绍

该接口用于更新告警分组规则。

调用方法

请参见如何调用API

URI

PUT /v2/{project_id}/alert/group-rules

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,可以从控制台获取,也可以从调用API处获取。获取方式请参见:获取项目ID

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

从IAM服务获取的用户Token。获取方式请参见:获取Token

Content-Type

String

消息体的类型(格式)。指定类型为“application/json”。

Enterprise-Project-Id

String

企业项目id。

  • 更新单个企业项目下告警分组规则列表,填写企业项目id。

  • 不填,更新默认企业项目下告警分组规则列表。

表3 请求Body参数

参数

是否必选

参数类型

描述

name

String

告警分组规则名称。名称不可修改。

只能由大小写字母、数字、下划线组成,且不能以下划线开头和结尾,最多不能超过100个字符。

desc

String

告警分组规则描述。规则描述长度最大 1024

match_v3

GroupV3Tag object

分组编排详情。(如果更新新版告警分组规则,该参数必填,如果更新告警分组规则,该参数为空)

detail

Array of GroupRuleDetail objects

告警分组规则的分组条件列表。(如果更新新版告警分组规则,该参数为空,如果更新告警分组规则,该参数必填)

分组条件最多可设置10个并行条件,每个并行条件下最多可设置10个串行条件,每个并行条件下可设置一个或多个AOM告警通知规则。

group_by

Array of strings

通知合并规则。(如果更新新版告警分组规则,该参数为空,如果更新告警分组规则,该参数必填)

  • resource_provider:告警源。

  • event_severity:严重度。

  • tags:标签,当告警分组条件里有标签条件时才支持。

目前仅支持如下通知规则组合:

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

智能通知合并规则。智能合并模式开关功能当前仅在华北-北京四,华南-广州区域开放。系统默认关闭智能合并模式开关,打开开关后,用户可以按照选择的告警属性智能合并告警。

数组为空时,表示不开启智能通知合并。

  • event_name : 告警名称。

  • alarm_info:告警信息。

  • tag:所有标签 仅当分组条件里有标签时生效。

表4 GroupV3Tag

参数

是否必选

参数类型

描述

nodes

Array of GroupConditionNode objects

节点详情列表。

必须包含开始节点,结束节点,card节点。

edges

Array of Edge objects

边详情列表。

表5 GroupConditionNode

参数

是否必选

参数类型

描述

id

String

节点id。命名规范为:flow-“8为随机字符串”。

随机字符串只能由字母、数字、下划线和中划线组成。

例如:flow-lvzgw9Td

type

String

节点类型。

  • Start:开始节点。

  • Card:卡片节点。

  • End:结束节点。

businessType

String

业务类型。(当nodeType为Card时,该参数必填)

  • GroupCondition:分组条件节点

  • CombineConf:通知合并节点

value

GroupConditionSubNode object

告警分组规则节点详情。(当nodeType为Card时,该参数必填)

表6 GroupConditionSubNode

参数

是否必选

参数类型

描述

nodes

Array of GroupConditionSubNode objects

子节点列表。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空)

id

String

节点id。命名规范:{businessType}-"8位随机字符串"。

随机字符串只能由字母、数字、下划线和中划线组成

例如:GroupCondition-Lh0dTxyd

type

String

节点类型。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空)

  • bool:布尔。

  • text:文本。

  • numerical:数字。

value

String

节点之间关系。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空)

  • and:且。

  • or:或。

match

MatchTag object

路由规则匹配条件列表。(当businessType为GroupCondition时,该参数必填,当businessType为CombineConf,该参数为空)

combineConfig

CombineConfig object

通知合并节点详情。(当businessType为GroupCondition时,该参数为空,当businessType为CombineConf,该参数为必填)

表7 MatchTag

参数

是否必选

参数类型

描述

key

String

分组条件key取值范围:

  • 具体标签名:标签只能包含中文、字母、数字和下划线

  • event_severity:告警级别

  • notification_scene:通知场景

  • resource_provider:告警源

  • resource_type:资源类型

value

Array of strings

分组条件value取值范围。当表达式为正则时,value的长度不能超过256

  • 当分组条件key为标签时,value取值范围为:标签名对应的标签值,标签值只能包含中文、字母、数字和下划线。

  • 当分组条件key为告警级别且表达式为等于时,value取值范围为:Critical,Major,Minor,Info。

  • 当分组条件key为通知场景时,value取值范围为:notify_resolved:告警恢复时,notify_triggered:告警触发时

  • 当分组条件key为告警源时,value取值范围为:触发告警或事件的服务名称。可以设置为AOM 、LTS、CCE等服务名称。

  • 当分组条件key为资源类型时,value取值范围为:创建告警规则或自定义上报告警时选定的资源类型。可以设置为:host、container、process等类型。

operate

String

操作符:

  • EQUALS :等于

  • REGEX :正则

  • EXIST :存在

表8 CombineConfig

参数

是否必选

参数类型

描述

group_by

Array of strings

通知合并规则。

  • resource_provider:告警源。

  • event_severity:严重度。

  • tag:标签,当告警分组条件里有标签条件时才支持。

目前仅支持如下通知规则组合:

1.按告警源 ["resource_provider"]

2.按告警源+严重度 ["resource_provider","event_severity"]

3.按告警源+所有标签 ["resource_provider","tag","event_severity","resource_type"]

ai_group_by

String

智能通知合并规则。 数组为空时,表示不开启智能通知合并。

  • event_name : 告警名称。

  • alarm_info:告警信息。

  • tag:所有标签,仅当分组条件里有标签时生效。

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

绑定告警行动规则名称列表。

表9 Edge

参数

是否必选

参数类型

描述

id

String

边id。命名规范为:edge-"8位随机字符串”。

随机字符串只能由字母、数字、下划线和中划线组成。

例如:edge-M3pfK202

source

String

边起始节点id。取值于nodes列表里的id。

target

String

边终止节点id。取值于nodes列表里的id。

value

String

边value。节点之间的关系true或false。

表10 GroupRuleDetail

参数

是否必选

参数类型

描述

match

Array of MatchTag objects

路由规则匹配条件列表。

bind_notification_rule_ids

Array of strings

绑定的告警通知规则名称。

响应参数

状态码:204

No Content 表示请求成功,但没有内容返回。

状态码:400

表11 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

最小长度:12

最大长度:12

error_msg

String

错误信息。

最小长度:0

最大长度:1024

error_type

String

错误类型。

最小长度:0

最大长度:128

trace_id

String

请求id。

最小长度:32

最大长度:32

状态码:403

表12 响应Body参数

参数

参数类型

描述

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.08003002",
  "error_msg" : "the groupName is not 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 请求被拒绝访问。返回该状态码,表明请求能够到达服务端,且服务端能够理解用户请求,但是拒绝做更多的事情,因为该请求被设置为拒绝访问,建议直接修改该请求,不要重试该请求。

错误码

请参见错误码

相关文档