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
Modifying a Custom Alarm Template
Function
This API is used to modify a custom alarm template.
URI
PUT /v2/{project_id}/alarm-templates/{template_id}
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}$ |
template_id |
Yes |
String |
ID of an alarm template. Minimum: 2 Maximum: 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 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. 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: 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: 404
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
Modifying a custom template whose template_name is my_template, including its metric period, aggregation method, threshold, unit, count, alarm suppression duration, and alarm severity.
{
"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
} ]
}
Example Responses
None
Status Codes
Status Code |
Description |
|---|---|
204 |
No Content |
400 |
Parameter verification failed. |
401 |
Authentication failed. |
403 |
Authentication failed. |
404 |
Resources not found. |
500 |
Failed to complete the request because of an internal server error. |
Error Codes
See Error Codes.