Querying the Alarm Template List
Function
This API is used to query the alarm template list.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
aom:alarmRuleTemplate:list
List
-
-
-
-
URI
GET /v4/{project_id}/alarm-rules-template
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Project ID, which can be obtained from the console or by calling an API. For details, see Obtaining a Project ID. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
Alarm template ID. |
|
type |
Yes |
String |
Alarm template type. Default: template. |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
User token obtained from IAM. For details, see Obtaining a Token. |
|
Content-Type |
No |
String |
Message body type or format. Content type, which is application/json. |
|
Enterprise-Project-Id |
No |
String |
Enterprise project ID. For details, see Obtaining an Enterprise Project ID. |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
alarm_rule_templates |
Array of AlarmRuleTemplateBody objects |
Alarm template list. |
|
count |
Integer |
Total number of alarm templates. |
|
Parameter |
Type |
Description |
|---|---|---|
|
alarm_rule_template_name |
String |
Alarm template name. |
|
alarm_rule_template_name_en |
String |
Name of an alarm template. |
|
alarm_rule_template_description |
String |
Alarm template description. |
|
alarm_rule_template_id |
String |
Alarm template ID. |
|
alarm_rule_template_project_id |
String |
Project ID, which can be obtained from the console or by calling an API. For details, see Obtaining a Project ID. |
|
alarm_rule_template_type |
String |
Alarm template type. |
|
alarm_rule_template_source |
String |
Source of an alarm template. |
|
alarm_rule_template_binding |
Map<String,String> |
Alarm rule bound to the alarm template. |
|
alarm_template_spec_list |
Array of AlarmRuleTemplateSpecWithCloudService objects |
Alarm template list. |
|
enterprise_project_id |
String |
Enterprise project ID. For details, see Obtaining an Enterprise Project ID. |
|
create_time |
Long |
Creation time (UTC timestamp, in milliseconds). Example: 2024-10-16 16:03:01 needs to be converted to UTC timestamp 1702759381000 using a tool. |
|
modify_time |
Long |
Update time (UTC timestamp, in milliseconds). Example: 2024-10-16 16:03:01 needs to be converted to UTC timestamp 1702759381000 using a tool. |
|
templating |
Templating object |
List of variables in an alarm template. |
|
template_version |
String |
Version of an alarm template. |
|
Parameter |
Type |
Description |
|---|---|---|
|
related_cloud_service |
String |
Associated cloud service. |
|
related_cce_clusters |
Array of strings |
Associated CCE cluster. |
|
related_prometheus_instances |
Array of strings |
Associated Prometheus instance. |
|
alarm_notification |
AlarmNotification object |
Notification information. |
|
alarm_template_spec_items |
Array of AlarmTemplateSpecItem objects |
Alarm template list. |
|
Parameter |
Type |
Description |
|---|---|---|
|
alarm_template_name |
String |
Name of an alarm rule in an alarm template. |
|
alarm_template_name_en |
String |
Name of an alarm rule in an alarm template. |
|
desc |
String |
Description of an alarm rule in an alarm template. |
|
desc_en |
String |
Description of an alarm rule in an alarm template. |
|
alarm_template_spec_type |
String |
Type of an alarm rule. |
|
metric_alarm_template_spec |
MetricAlarmTemplateSpec object |
Metric alarm template. |
|
event_alarm_template_spec |
EventAlarmTemplateSpec object |
Event alarm template. |
|
Parameter |
Type |
Description |
|---|---|---|
|
alarm_subtype |
String |
Definition Alarm rule type. Range |
|
alarm_source |
String |
Alarm source, for example, CCE. |
|
monitor_type |
String |
Definition Monitoring type. Range |
|
trigger_conditions |
Array of TemplateTriggerCondition objects |
Trigger condition. |
|
no_data_conditions |
Array of NoDataCondition objects |
Action taken when data is insufficient. |
|
alarm_tags |
Array of AlarmTags objects |
Alarm tag. |
|
recovery_conditions |
RecoveryCondition object |
Alarm clearance condition. |
|
Parameter |
Type |
Description |
|---|---|---|
|
metric_query_mode |
String |
Metric query mode. |
|
metric_namespace |
String |
Metric namespace. |
|
metric_name |
String |
Metric name. |
|
metric_unit |
String |
Metric unit. |
|
metric_labels |
Array of strings |
Metric dimension. |
|
promql |
String |
Prometheus statement. |
|
promql_expr |
String |
Prometheus statement template. |
|
trigger_times |
Integer |
Number of consecutive periods. |
|
trigger_interval |
String |
Check interval.
|
|
trigger_type |
String |
Trigger frequency. Options: |
|
promql_for |
String |
Duration. Options: |
|
aggregation_type |
String |
Detection rule. Options: |
|
operator |
String |
Comparison operator. Options: >, <, =, >=, and <=. |
|
thresholds |
Map<String,String> |
Key-value pair. The key indicates the alarm severity while the value indicates the alarm threshold. |
|
aggregation_window |
String |
Statistical period. Options: |
|
cmdb |
CmdbInfo object |
CMDB information. |
|
query_match |
String |
Query filter criteria. |
|
aom_monitor_level |
String |
Monitoring layer. |
|
aggregate_type |
String |
Aggregation mode. |
|
metric_statistic_method |
String |
Metric statistics method to be used when you set Configuration Mode to Select from all metrics during alarm rule setting. |
|
expression |
String |
Expression of a combined operation. |
|
mix_promql |
String |
PromQL of a combined operation. |
|
alarm_message_template |
String |
Notification content. |
|
promql_monitor_templates |
Array of strings |
Prometheus monitoring template. Default: cluster. |
|
query_param |
Object |
|
Parameter |
Type |
Description |
|---|---|---|
|
app_id |
String |
Application ID. |
|
node_ids |
Array of NodeInfo objects |
Node information list. |
|
Parameter |
Type |
Description |
|---|---|---|
|
no_data_timeframe |
Integer |
Number of consecutive periods without data. Value range: 1–5. (If notify_no_data is set to true, this parameter is mandatory. If notify_no_data is set to false, leave this parameter blank.) |
|
no_data_alert_state |
String |
Status of the threshold rule when the data is insufficient. (If notify_no_data is set to true, this parameter is mandatory. If notify_no_data is set to false, leave this parameter blank.) |
|
notify_no_data |
Boolean |
Whether to take action when no data is reported. true: Enable the function. false: Disable the function. |
|
Parameter |
Type |
Description |
|---|---|---|
|
auto_tags |
Array of strings |
Automatic tag. |
|
custom_tags |
Array of strings |
Custom tag. |
|
custom_annotations |
Array of strings |
Alarm annotation. |
|
Parameter |
Type |
Description |
|---|---|---|
|
recovery_timeframe |
Integer |
Number of consecutive periods for which the trigger condition is not met to clear an alarm. Value range: 1–3. (If recovery_timeframe is specified, this parameter is mandatory.) |
|
Parameter |
Type |
Description |
|---|---|---|
|
alarm_subtype |
String |
Alarm rule type. |
|
alarm_source |
String |
Alarm source, for example, CCE. |
|
event_source |
String |
Event source. |
|
monitor_object_templates |
Array of strings |
Monitored object template. Currently, only clusterId is supported. |
|
monitor_objects |
Array of Map<String,String> objects |
List of monitored objects. Key-value pair. |
|
trigger_conditions |
Array of EventTriggerCondition objects |
Trigger condition. |
|
Parameter |
Type |
Description |
|---|---|---|
|
event_name |
String |
Event name. |
|
trigger_type |
String |
Trigger mode. |
|
aggregation_window |
Long |
Monitoring period. Unit: second. For example, 3600 indicates 1 hour. If trigger_type is set to immediately, leave this parameter blank. If trigger_type is set to accumulative, this parameter is mandatory. Value range: 5 minutes, 20 minutes, 1 hour, 4 hours, or 24 hours. |
|
operator |
String |
Operator. Options: >, <, =, >=, and <=. If trigger_type is set to immediately, leave this parameter blank. If trigger_type is set to accumulative, this parameter is mandatory. |
|
thresholds |
Map<String,Integer> |
Key-value pair. The key indicates the alarm severity while the value indicates the number of accumulated trigger times. If trigger_type is set to immediately, the value is 1. If trigger_type is set to accumulative, the value ranges from 1 to 100. (This parameter is mandatory if trigger_conditions is specified.) |
|
frequency |
String |
Event alarm notification frequency. If trigger_type is set to immediately, the value of this parameter is -1. |
Example Requests
Example Responses
Status code: 200
OK: The request is successful.
{
"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 Sample Code
The SDK sample code is as follows.
Java
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()); } } } |
Python
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) |
Go
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) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
OK: The request is successful. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot