
# 查询告警分组规则列表 - ListGroupRules
#### 功能介绍
该接口用于查询告警分组规则列表。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-aom/aom_04_0057.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-aom/aom_04_0031.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                     | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | aom:routeGroupRule:list | List | -           | -   | -  | -      |
     
  
 
#### URI
GET /v2/{project_id}/alert/group-rules
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                     |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID，可以从控制台获取，也可以从调用API处获取。获取方式请参见：[获取项目ID](https://support.huaweicloud.com/api-aom/aom_04_0024.html)。 |
   
#### 请求参数
表2请求Header参数 
| 参数                    | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|:---|
| X-Auth-Token          | 是    | String | 从IAM服务获取的用户Token。获取方式请参见：[获取Token](https://support.huaweicloud.com/api-aom/aom_04_0059.html)。                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Content-Type          | 是    | String | 消息体的类型（格式）。指定类型为"application/json"。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Enterprise-Project-Id | 否    | String | 企业项目id。 - 查询单个企业项目下告警分组规则列表，填写企业项目id。   - 查询所有企业项目下告警分组规则列表，填写"all_granted_eps"。   - 不填，查询默认企业项目下告警分组规则列表。    |
   
#### 响应参数
**状态码：200**
表3响应Body参数 
| 参数       | 参数类型                                                              | 描述          |
|:---|:---|:---|
| \[数组元素\] | Array of [GroupRule] objects | 查询告警分组规则列表。 |
   
 表4GroupRule 
| 参数                    | 参数类型                                                                          | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|
| desc                  | String                                                                        | 告警分组规则描述。规则描述长度最大 1024                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 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"\] |
| ai_group_by           | Array of strings                                                              | 智能通知合并规则。 数组为空时，表示不开启智能通知合并。 - 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| create_time           | Long                                                                          | 创建告警分组规则时间。仅支持UTC毫秒级时间戳。例如：2024-10-16 16:03:01需要通过工具转换成UTC毫秒级时间戳：1702759381000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| update_time           | Long                                                                          | 更新告警分组规则时间。仅支持UTC毫秒级时间戳。例如：2024-10-16 16:03:01需要通过工具转换成UTC毫秒级时间戳：1702759381000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| type                  | String                                                                        | 规则类型： CUSTOM：自定义                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| detail                | Array of [GroupRuleDetail] objects | 告警分组规则的分组条件列表。（分组规则参数）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| user_id               | String                                                                        | 告警分组规则所属projectid。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| name                  | String                                                                        | 告警分组规则名称。 只能由大小写字母、数字、下划线组成，且不能以下划线开头和结尾，最多不能超过100个字符。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| enterprise_project_id | String                                                                        | 告警分组规则所属企业项目id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| match_v3              | [GroupV3Tag] object                     | 告警分组编排详情。（新版告警分组规则详情）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| parent                | String                                                                        | 继承规则，默认值：aom-builtin-group。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
   
 表5GroupRuleDetail 
| 参数                         | 参数类型                                                            | 描述           |
|:---|:---|:---|
| match                      | Array of [MatchTag] objects | 匹配条件列表。      |
| bind_notification_rule_ids | Array of strings                                                | 绑定的告警通知规则名称。 |
   
 表6MatchTag 
| 参数      | 参数类型             | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|
| 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 ：存在                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
   
 表7GroupV3Tag 
| 参数    | 参数类型                                                                                | 描述                                                              |
|:---|:---|:---|
| nodes | Array of [GroupConditionNode] objects | 节点详情列表。 必须包含开始节点，结束节点，card节点。 |
| edges | Array of [Edge] objects                             | 边详情列表。                                                          |
   
 表8GroupConditionNode 
| 参数           | 参数类型                                                                            | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|
| id           | String                                                                          | 节点id。命名规范为：flow-"8位随机字符串"。 随机字符串只能由字母、数字、下划线和中划线组成。 例如：flow-lvzgw9Td                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| type         | String                                                                          | 节点类型。 - Start：开始节点。   - Card：卡片节点。   - End：结束节点。                                                                                                                              |
| businessType | String                                                                          | **参数解释：** 业务类型。 **约束限制：** 当nodeType为Card时，该参数必填。 **取值范围：** - GroupCondition：分组条件节点   - CombineConf：通知合并节点    **默认取值：** 不涉及。 |
| value        | [GroupConditionSubNode] object | 告警分组规则节点详情。（当nodeType为Card时，该参数必填）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
   
 表9GroupConditionSubNode 
| 参数            | 参数类型                                                                                      | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|
| 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，该参数为必填）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
   
 表10CombineConfig 
| 参数                         | 参数类型             | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|:---|:---|:---|
| 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                | Array of strings | 智能通知合并规则。 数组为空时，表示不开启智能通知合并。 - 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 | 绑定告警行动规则名称列表。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
   
 表11Edge 
| 参数     | 参数类型   | 描述                                                                                                                                      |
|:---|:---|:---|
| id     | String | 边id。命名规范为：edge-"8位随机字符串"。 随机字符串只能由字母、数字、下划线和中划线组成。 例如：edge-M3pfK202 |
| source | String | 边起始节点id。取值于nodes列表里的id。                                                                                                                 |
| target | String | 边终止节点id。取值于nodes列表里的id。                                                                                                                 |
| value  | String | 边value。节点之间的关系true或false。                                                                                                               |
   
**状态码：403**
表12响应Body参数 
| 参数         | 参数类型   | 描述                                                                                                                                      |
|:---|:---|:---|
| error_code | String | **参数解释：** 非法请求错误码。 **取值范围：** 不涉及。 |
| error_msg  | String | **参数解释：** 错误信息。 **取值范围：** 不涉及。    |
| error_type | String | **参数解释：** 错误类型。 **取值范围：** 不涉及。    |
| trace_id   | String | **参数解释：** 请求id。 **取值范围：** 不涉及。    |
   
#### 请求示例
查询告警分组规则列表
```
https://{Endpoint}/v2/{project_id}/alert/group-rules
```
#### 响应示例
**状态码：200**
请求响应成功。
```
[ {
  "ai_group_by" : [ ],
  "create_time" : 1720600705978,
  "desc" : "",
  "detail" : [ {
    "bind_notification_rule_ids" : [ "0001112223" ],
    "match" : [ {
      "key" : "resource_provider",
      "operate" : "EQUALS",
      "value" : [ "AOM" ]
    } ]
  }, {
    "bind_notification_rule_ids" : [ "0001112223" ],
    "match" : [ {
      "key" : "event_severity",
      "operate" : "EQUALS",
      "value" : [ "Major" ]
    } ]
  } ],
  "enterprise_project_id" : "0",
  "group_by" : [ "resource_provider" ],
  "group_interval" : 5,
  "group_repeat_waiting" : 60,
  "group_wait" : 0,
  "name" : "1212",
  "parent" : "aom-builtin-group",
  "type" : "CUSTOM",
  "update_time" : 1720666840356,
  "user_id" : "2a473356cca5487f8373be891bffc1cf"
} ]
```
**状态码：403**
Forbidden 请求被拒绝访问。返回该状态码，表明请求能够到达服务端，且服务端能够理解用户请求，但是拒绝做更多的事情，因为该请求被设置为拒绝访问，建议直接修改该请求，不要重试该请求。
```
{
  "error_code" : "AOM.0403",
  "error_msg" : "auth failed.",
  "error_type" : "AUTH_FAILED",
  "trace_id" : ""
}
```
#### 状态码
| 状态码 | 描述                                                                                            |
|:---|:---|
| 200 | 请求响应成功。                                                                                       |
| 403 | Forbidden 请求被拒绝访问。返回该状态码，表明请求能够到达服务端，且服务端能够理解用户请求，但是拒绝做更多的事情，因为该请求被设置为拒绝访问，建议直接修改该请求，不要重试该请求。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-aom/ErrorCode.html)。
