Files
doc-exports/docs/ces/api-ref/UpdateAlarmTemplate.html
qiujiandong1 e9265fb6b0 CES API Update -20250521 version
Reviewed-by: Ziuzko, Alevtina <alevtina.ziuzko@t-systems.com>
Co-authored-by: qiujiandong1 <qiujiandong1@huawei.com>
Co-committed-by: qiujiandong1 <qiujiandong1@huawei.com>
2025-12-05 10:48:24 +00:00

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}

Table 1 Path parameters

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

Table 2 Request header 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

Table 3 Request body parameters

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:

  • 0: metric template

  • 2: event template

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

Table 4 Policies

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:

  • 0

  • 1

  • 300

  • 1200

  • 3600

  • 14400

  • 86400

filter

Yes

String

Data aggregation method. The value can be:

  • average: average value of metric data within an aggregation period.
  • max: maximum value of metric data in an aggregation period.
  • min: minimum value of metric data within an aggregation period.
  • sum: sum of metric data within an aggregation period.
  • variance: variance value of metric data within an aggregation period.

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:

  • 0

  • 300

  • 600

  • 900

  • 1800

  • 3600

  • 10800

  • 21600

  • 43200

  • 86400

Response Parameters

Status code: 400

Table 5 Response body parameters

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

Table 6 Response body parameters

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

Table 7 Response body parameters

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

Table 8 Response body parameters

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

Table 9 Response body parameters

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.