Reviewed-by: Ziuzko, Alevtina <alevtina.ziuzko@t-systems.com> Co-authored-by: qiujiandong1 <qiujiandong1@huawei.com> Co-committed-by: qiujiandong1 <qiujiandong1@huawei.com>
58 KiB
Creating a Custom Alarm Template
Function
This API is used to create a custom alarm template.
URI
POST /v2/{project_id}/alarm-templates
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. Minimum: 1 Maximum: 64 Regular expression matching: ^[a-zA-Z0-9-]{1,64}$ |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. It is a response to the API for obtaining a user token. This API is the only one that does not require authentication. After a response is returned, the value of X-Subject-Token in the response header is the token. Minimum: 1 Maximum: 16384 |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
template_name |
Yes |
String |
Alarm template name. It must start with a letter and can contain letters, digits, underscores (_), hyphens (-), parentheses, and periods (.). Fuzzy match is supported. Minimum: 1 Maximum: 128 Regular expression matching: ^([\u4E00-\u9FFF]|[a-z]|[A-Z]|[0-9]|_|-|\(|\)|\.|\s)+$ |
template_type |
No |
Integer |
Type of a custom alarm template. The value can be: |
template_description |
No |
String |
Supplementary information about an alarm template. The description can contain 0 to 256 characters and is left blank by default. |
policies |
Yes |
Array of Policies objects |
Alarm policies in an alarm template. Array length: 1 to 50 |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
namespace |
Yes |
String |
Namespace. Namespace of a service. For details about the namespace of each service, see Service Namespaces. The namespace must be in the service.item format and contain 3 to 32 characters. service and item must start with a letter and can contain only letters, digits, and underscores (_). Minimum: 3 Maximum: 32 |
dimension_name |
No |
String |
Resource dimension, which must start with a letter. A dimension allows a maximum of 32 characters can only contain digits, letters, underscores (_), and hyphens (-). If there are multiple dimensions, use commas (,) to separate them. DimensionName in event alarm templates must be left blank. |
metric_name |
Yes |
String |
Metric name of a resource. For details about the metrics of each service, see Service Metric Names. The value must start with a letter and can only contain digits, letters, underscores (_), and hyphens (-). It allows 1 to 96 characters. For example, the ECS metric cpu_util indicates the CPU usage of an ECS. The DDS metric mongo001_command_ps indicates the command execution frequency. Regular expression matching: ^([A-Za-z]){1}([0-9A-Za-z]|_|-)*$ |
period |
Yes |
Integer |
Interval (seconds) for checking whether the alarm rule conditions are met. 0: default value. For example, this value can be used for event alarms. 1: original aggregation period of a metric. For example, if the original aggregation period of an RDS metric is 60s, its data point is calculated every 60 seconds. For details about the original aggregation period of each cloud service metric, see Services Interconnected with Cloud Eye. 300: The metric data is collected and calculated every 5 minutes. 1200: The metric data is collected and calculated every 20 minutes. 3600: The metric data is collected and calculated every 1 hour. 14400: The metric data is collected and calculated every 4 hours. 86400: The metric data is collected and calculated every day. The value can be: |
filter |
Yes |
String |
Data aggregation method. The value can be:
|
comparison_operator |
Yes |
String |
Operator of an alarm threshold. Regular expression matching: ^(>|<|>=|<=|=|!=)$ |
value |
No |
Number |
Alarm threshold. Minimum: 0 Maximum: Number.MAX_VALUE (1.7976931348623156E108) |
unit |
No |
String |
Data unit. The value can contain a maximum of 32 characters. You can set this parameter based on your service needs. Minimum: 0 Maximum: 32 |
count |
Yes |
Integer |
Number of consecutive alarm triggering times. For event alarms, the value ranges from 1 to 180. For metric and website alarms, the value can be 1, 2, 3, 4, 5, 10, 15, 30, 60, 90, 120, or 180. |
alarm_level |
No |
Integer |
Alarm severity, which can be 1 (critical), 2 (major), 3 (minor), or 4 (warning). The default value is 2. |
suppress_duration |
Yes |
Integer |
Alarm suppression period, in seconds. When the period is 0, only one alarm is generated. The value can be: |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
|---|---|---|
template_id |
String |
ID of an alarm template. The ID starts with at and is followed by letters, digits, or a combination of both. The value can contain a maximum of 64 characters. |
Status code: 400
Parameter |
Type |
Description |
|---|---|---|
error_code |
String |
Status code customized by each cloud service when a request error occurs. Minimum: 0 Maximum: 256 |
error_msg |
String |
Request error message. Minimum: 0 Maximum: 256 |
request_id |
String |
Request ID. Minimum: 0 Maximum: 256 |
Status code: 401
Parameter |
Type |
Description |
|---|---|---|
error_code |
String |
Status code customized by each cloud service when a request error occurs. Minimum: 0 Maximum: 256 |
error_msg |
String |
Request error message. Minimum: 0 Maximum: 256 |
request_id |
String |
Request ID. Minimum: 0 Maximum: 256 |
Status code: 403
Parameter |
Type |
Description |
|---|---|---|
error_code |
String |
Status code customized by each cloud service when a request error occurs. Minimum: 0 Maximum: 256 |
error_msg |
String |
Request error message. Minimum: 0 Maximum: 256 |
request_id |
String |
Request ID. Minimum: 0 Maximum: 256 |
Status code: 500
Parameter |
Type |
Description |
|---|---|---|
error_code |
String |
Status code customized by each cloud service when a request error occurs. Minimum: 0 Maximum: 256 |
error_msg |
String |
Request error message. Minimum: 0 Maximum: 256 |
request_id |
String |
Request ID. Minimum: 0 Maximum: 256 |
Example Requests
{
"template_name" : "my_template",
"template_description" : "hello world",
"policies" : [ {
"namespace" : "SYS.ECS",
"dimension_name" : "instance_id",
"metric_name" : "cpu_util",
"period" : 300,
"filter" : "sum",
"comparison_operator" : ">",
"value" : 2,
"unit" : "bit/s",
"count" : 2,
"alarm_level" : 2,
"suppress_duration" : 300
} ],
"template_type": 0
}
Creating an event template whose template_name is my_event_template, metric_name is rebootServer, count is 1, and alarm_level is 2
{
"template_name" : "my_event_template",
"template_description" : "hello world",
"policies" : [ {
"namespace" : "SYS.ECS",
"dimension_name" : "",
"metric_name" : "rebootServer",
"period" : 0,
"filter" : "average",
"comparison_operator" : ">=",
"value" : 1,
"unit" : "count",
"count" : 1,
"alarm_level" : 2,
"suppress_duration" : 0
} ],
"template_type": 2
}
Example Responses
Status code: 201
Created
{
"template_id" : "at1628592157541dB1klWgY6"
}
Status Codes
Status Code |
Description |
|---|---|
201 |
Created |
400 |
Parameter verification failed. |
401 |
Authentication failed. |
403 |
Authentication failed. |
500 |
Failed to complete the request because of an internal server error. |
Error Codes
See Error Codes.