查询告警模板列表 - ListAlarmRuleTemplate
功能介绍
该接口用于查询告警模板列表。
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
授权项
访问级别
资源类型(*为必须)
条件键
别名
依赖的授权项
aom:alarmRuleTemplate:list
List
-
-
-
-
URI
GET /v4/{project_id}/alarm-rules-template
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
项目ID,可以从控制台获取,也可以从调用API处获取。获取方式请参见:获取项目ID。 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
id |
否 |
String |
告警模板id。 |
|
type |
是 |
String |
告警模板类型。默认值为“template” |
请求参数
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
alarm_rule_templates |
Array of AlarmRuleTemplateBody objects |
告警模板列表。 |
|
count |
Integer |
告警模板总数。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
alarm_rule_template_name |
String |
告警模板名称。 |
|
alarm_rule_template_name_en |
String |
告警模板英文名称。 |
|
alarm_rule_template_description |
String |
告警模板描述。 |
|
alarm_rule_template_id |
String |
告警模板id。 |
|
alarm_rule_template_project_id |
String |
项目ID,可以从控制台获取,也可以从调用API处获取。获取方式请参见:获取项目ID。 |
|
alarm_rule_template_type |
String |
告警模板类型
|
|
alarm_rule_template_source |
String |
告警模板来源。 |
|
alarm_rule_template_binding |
Map<String,String> |
告警模板所绑定的告警规则。 |
|
alarm_template_spec_list |
Array of AlarmRuleTemplateSpecWithCloudService objects |
告警模板列表。 |
|
enterprise_project_id |
String |
企业项目id。获取方式请参见:获取企业项目ID。 |
|
create_time |
Long |
创建时间。 |
|
modify_time |
Long |
更新时间。 |
|
templating |
Templating object |
告警模板变量列表。 |
|
template_version |
String |
告警模板版本。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
related_cloud_service |
String |
关联的云服务。 |
|
related_cce_clusters |
Array of strings |
关联的CCE集群。 |
|
related_prometheus_instances |
Array of strings |
关联的Prom实例。 |
|
alarm_notification |
AlarmNotification object |
通知信息。 |
|
alarm_template_spec_items |
Array of AlarmTemplateSpecItem objects |
告警模板列表。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
notification_type |
String |
通知类型。
枚举值:
|
|
route_group_enable |
Boolean |
启用告警分组规则。
如果告警触发“notify_triggered”或告警恢复“notify_resolved”都设置为false(即都不进行告警通知),则route_group_enable需设置为false。 枚举值:
|
|
route_group_rule |
String |
告警分组规则名称。
|
|
notification_enable |
Boolean |
是否启用告警通知规则。
如果告警触发“notify_triggered”或告警恢复“notify_resolved”都设置为false(即都不进行告警通知),则notification_enable需设置为false。 |
|
bind_notification_rule_id |
String |
告警行动策略id。
|
|
notify_resolved |
Boolean |
告警解决是否通知。
枚举值:
|
|
notify_triggered |
Boolean |
告警触发是否通知。
枚举值:
|
|
notify_frequency |
Integer |
通知频率
|
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
alarm_template_name |
String |
告警模板下单个告警规则名称。 |
|
alarm_template_name_en |
String |
告警模板下单个告警规则英文名称。 |
|
desc |
String |
告警模板下单个告警规则描述。 |
|
desc_en |
String |
告警模板下单个告警规则英文描述。 |
|
alarm_template_spec_type |
String |
告警模板下单个告警规则类型。 “metric”:指标告警 “event”:事件告警 |
|
metric_alarm_template_spec |
MetricAlarmTemplateSpec object |
指标告警模板。 |
|
event_alarm_template_spec |
EventAlarmTemplateSpec object |
事件告警模板。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
alarm_subtype |
String |
告警规则类别。 |
|
alarm_source |
String |
告警规则来源云服务:CCE 创建标识。 |
|
monitor_type |
String |
监控类型。 |
|
trigger_conditions |
Array of TemplateTriggerCondition objects |
触发条件。 |
|
no_data_conditions |
Array of NoDataCondition objects |
数据不足条件。 |
|
alarm_tags |
Array of AlarmTags objects |
告警标签。 |
|
recovery_conditions |
RecoveryCondition object |
告警恢复条件。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
metric_query_mode |
String |
指标查询模式。
枚举值:
|
|
metric_namespace |
String |
指标命名空间。 |
|
metric_name |
String |
指标名称。 |
|
metric_unit |
String |
指标单位。 |
|
metric_labels |
Array of strings |
指标维度。 |
|
promql |
String |
Prometheus语句。 |
|
promql_expr |
String |
Prometheus语句模板。 |
|
trigger_times |
Integer |
连续周期个数。 |
|
trigger_interval |
String |
检查频率周期。
|
|
trigger_type |
String |
触发频率的类型:
枚举值:
|
|
promql_for |
String |
持续时间。 持续时间范围:
|
|
aggregation_type |
String |
检测规则:
|
|
operator |
String |
判断条件:“>”,“<”,“=”,“>=”,“<=” |
|
thresholds |
Map<String,String> |
键值对形式,键为告警级别,值为告警阈值 |
|
aggregation_window |
String |
统计周期。
|
|
cmdb |
CmdbInfo object |
cmdb信息。 |
|
query_match |
String |
查询筛选条件。 |
|
aom_monitor_level |
String |
监控层级。 |
|
aggregate_type |
String |
聚合方式。
枚举值:
|
|
metric_statistic_method |
String |
当配置方式为全量指标时可选择的指标运算方式。
枚举值:
|
|
expression |
String |
混合运算的表达式。 |
|
mix_promql |
String |
混合运算的promQL。 |
|
alarm_message_template |
String |
通知内容。 |
|
promql_monitor_templates |
Array of strings |
Prometheus监控模板。默认为cluster。 |
|
query_param |
Object |
|
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
no_data_timeframe |
Integer |
无数据处理连续周期。取值范围为1~5。(当"notify_no_data"为true时,该参数必填,当"notify_no_data"为false时,该参数为空) |
|
no_data_alert_state |
String |
数据不足时,阈值规则的状态。(当"notify_no_data"为true时,该参数必填,当"notify_no_data"为false时,该参数为空)
枚举值:
|
|
notify_no_data |
Boolean |
无数据处理开关。true表示启用无数据处理,false表示关闭无数据处理。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
auto_tags |
Array of strings |
自动标签。 |
|
custom_tags |
Array of strings |
自定义标签。 |
|
custom_annotations |
Array of strings |
告警标注。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
recovery_timeframe |
Integer |
告警恢复周期的个数。取值范围为1~3 (如果recovery_timeframe 参数不为空,该参数必填) |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
alarm_subtype |
String |
告警规则类别。 |
|
alarm_source |
String |
告警规则来源云服务:CCE 创建标识。 |
|
event_source |
String |
告警来源。 |
|
monitor_object_templates |
Array of strings |
监控对象模板(创建告警时需要补齐里面的内容)。 |
|
monitor_objects |
Array of Map<String,String> objects |
监控对象列表。键值对形式,键值为:
|
|
trigger_conditions |
Array of EventTriggerCondition objects |
触发条件。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
event_name |
String |
事件名称。 |
|
trigger_type |
String |
触发方式:
枚举值:
|
|
aggregation_window |
Long |
监控周期。单位为秒,例如 1小时 填“3600”,当trigger_type为“immediately”时 该参数为空,当trigger_type为“accumulative”时 该参数必填。 监控周期范围: 5分钟,20分钟,1小时,4小时,24小时。 |
|
operator |
String |
判断条件:“>”,“<”,“=”,“>=”,“<=”,当trigger_type为“immediately”时 该参数为空。当trigger_type为“accumulative”时 该参数必填。 |
|
thresholds |
Map<String,Integer> |
键值对形式,键为告警级别,值为累计次数,当trigger_type为“immediately”时 累计次数为1。当当trigger_type为“accumulative”时 累计次数范围为1~100 (如果trigger_conditions参数不为空,该参数必填) |
|
frequency |
String |
事件类告警频率。当trigger_type为“immediately”时 值为-1。
|
请求示例
-
查询告警模板列表
https://{Endpoint}/v4/{project_id}/alarm-rules-template -
查询告警模板id为12142546931的告警模板
https://{Endpoint}/v4/{project_id}/alarm-rules-template?id=1214****2546****931
响应示例
状态码:200
OK 请求响应成功。
{
"alarm_rule_templates" : [ {
"alarm_rule_template_binding" : { },
"alarm_rule_template_id" : "130****1802****3121",
"alarm_rule_template_name" : "aomTemplate",
"alarm_rule_template_project_id" : "2a47****cca5****8373****1bff****",
"alarm_rule_template_type" : "statics",
"alarm_template_spec_list" : [ {
"alarm_template_spec_items" : [ ],
"related_cce_clusters" : [ ],
"related_cloud_service" : "VPC",
"related_prometheus_instances" : [ ]
} ],
"create_time" : 1732266984780,
"enterprise_project_id" : "0",
"modify_time" : 1732266984780
} ],
"count" : 119
}
SDK代码示例
SDK代码示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.aom.v2.region.AomRegion; import com.huaweicloud.sdk.aom.v2.*; import com.huaweicloud.sdk.aom.v2.model.*; public class ListAlarmRuleTemplateSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); AomClient client = AomClient.newBuilder() .withCredential(auth) .withRegion(AomRegion.valueOf("<YOUR REGION>")) .build(); ListAlarmRuleTemplateRequest request = new ListAlarmRuleTemplateRequest(); try { ListAlarmRuleTemplateResponse response = client.listAlarmRuleTemplate(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkaom.v2.region.aom_region import AomRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkaom.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = AomClient.new_builder() \ .with_credentials(credentials) \ .with_region(AomRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListAlarmRuleTemplateRequest() response = client.list_alarm_rule_template(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" aom "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := aom.NewAomClient( aom.AomClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListAlarmRuleTemplateRequest{} response, err := client.ListAlarmRuleTemplate(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
OK 请求响应成功。 |
错误码
请参见错误码。