Updated on 2023-05-06 GMT+08:00

Modifying Alarm Policies

Function

This API is used to modify alarm policies.

URI

PUT /v2/{project_id}/alarms/{alarm_id}/policies

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the tenant ID.

Minimum: 1

Maximum: 64

Regex Pattern: ^[a-zA-Z0-9-]{1,64}$

alarm_id

Yes

String

Specifies the ID of the instance for which the alarm rule is configured.

Regex Pattern: ^al([0-9A-Za-z]){22}$

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Specifies the MIME type of a request body. The default type is application/json; charset=UTF-8.

Default: application/json; charset=UTF-8

Minimum: 1

Maximum: 64

X-Auth-Token

Yes

String

Specifies the user token.

Minimum: 1

Maximum: 16384

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

policies

Yes

Array of Policy objects

Specifies the policy information.

Table 4 Policy

Parameter

Mandatory

Type

Description

metric_name

Yes

String

Specifies the metric name of a resource. The name must start with a letter and contain only letter, digits, and underscores (_) . The length ranges from 1 to 64 characters. For example, cpu_util of an ECS indicates the CPU usage of the ECS. mongo001_command_ps in DDS indicates the command execution frequency. For details about the metric name of each service, see Service metric name.

period

Yes

Integer

Specifies the monitoring period of a metric, in seconds. The default value is 0. For example, for an event alarm, set this parameter to 0. 1 indicates the original monitoring period of the metric. For example, if the original period of an RDS metric is 60s, the RDS metric is calculated every 60 seconds as a data point. For details about the original period of each cloud service metric, see the Namespace column. 300 indicates that the metric is calculated every 5 minutes as a data point.

Minimum: 0

Maximum: 86400

Enumeration values:

  • 0

  • 1

  • 300

  • 1200

  • 3600

  • 14400

  • 86400

filter

Yes

String

Specifies the aggregation method. The value can be average, min, max, or sum.

comparison_operator

Yes

String

Specifies the threshold operator, which can be >, <, >=, <=, =, or ><.

value

Yes

Number

Specifies the threshold.

unit

No

String

Specifies the unit.

count

Yes

Integer

Specifies the number of counts that the threshold is met.

suppress_duration

No

Integer

Specifies the alarm suppression time, in seconds. This field corresponds to the last field of the alarm policy when an alarm rule is created on the Cloud Eye console. This field is used to avoid frequent alarms. 0 indicates that the alarm is not suppressed and an alarm is generated when the condition is met. 300 indicates that an alarm is generated every 5 minutes after the alarm triggering condition is met.

Minimum: 0

Maximum: 86400

Enumeration values:

  • 0

  • 300

  • 600

  • 900

  • 1800

  • 3600

  • 10800

  • 21600

  • 43200

  • 86400

level

No

Integer

Specifies the alarm severity, which can be: 1 (critical), 2 (major), 3 (minor) or 4 (informational).

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

policies

Array of Policy objects

Specifies the policy information.

Table 6 Policy

Parameter

Type

Description

metric_name

String

Specifies the metric name of a resource. The name must start with a letter and contain only letter, digits, and underscores (_) . The length ranges from 1 to 64 characters. For example, cpu_util of an ECS indicates the CPU usage of the ECS. mongo001_command_ps in DDS indicates the command execution frequency. For details about the metric name of each service, see Service metric name.

period

Integer

Specifies the monitoring period of a metric, in seconds. The default value is 0. For example, for an event alarm, set this parameter to 0. 1 indicates the original monitoring period of the metric. For example, if the original period of an RDS metric is 60s, the RDS metric is calculated every 60 seconds as a data point. For details about the original period of each cloud service metric, see the Namespace column. 300 indicates that the metric is calculated every 5 minutes as a data point.

Minimum: 0

Maximum: 86400

Enumeration values:

  • 0

  • 1

  • 300

  • 1200

  • 3600

  • 14400

  • 86400

filter

String

Specifies the aggregation method. The value can be average, min, max, or sum.

comparison_operator

String

Specifies the threshold operator, which can be >, <, >=, <=, =, or ><.

value

Number

Specifies the threshold.

unit

String

Specifies the unit.

count

Integer

Specifies the number of counts that the threshold is met.

suppress_duration

Integer

Specifies the alarm suppression time, in seconds. This field corresponds to the last field of the alarm policy when an alarm rule is created on the Cloud Eye console. This field is used to avoid frequent alarms. 0 indicates that the alarm is not suppressed and an alarm is generated when the condition is met. 300 indicates that an alarm is generated every 5 minutes after the alarm triggering condition is met.

Minimum: 0

Maximum: 86400

Enumeration values:

  • 0

  • 300

  • 600

  • 900

  • 1800

  • 3600

  • 10800

  • 21600

  • 43200

  • 86400

level

Integer

Specifies the alarm severity, which can be: 1 (critical), 2 (major), 3 (minor) or 4 (informational).

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the status codes customized by each cloud service when a request error occurs.

Minimum: 0

Maximum: 256

error_msg

String

Specifies the request error message.

Minimum: 0

Maximum: 256

request_id

String

Specifies the request ID.

Minimum: 0

Maximum: 256

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Specifies the status codes customized by each cloud service when a request error occurs.

Minimum: 0

Maximum: 256

error_msg

String

Specifies the request error message.

Minimum: 0

Maximum: 256

request_id

String

Specifies the request ID.

Minimum: 0

Maximum: 256

Example Requests

{
  "policies" : [ {
    "metric_name" : "disk_device_read_bytes_rate",
    "period" : 1,
    "filter" : "average",
    "comparison_operator" : ">",
    "value" : 75,
    "unit" : "byte/s",
    "count" : 3,
    "suppress_duration" : 10800,
    "level" : 2
  } ]
}

Example Responses

Status code: 200

Alarm policy modified.

{
  "policies" : [ {
    "metric_name" : "disk_device_read_bytes_rate",
    "period" : 1,
    "filter" : "average",
    "comparison_operator" : ">",
    "value" : 75,
    "unit" : "byte/s",
    "count" : 3,
    "suppress_duration" : 10800,
    "level" : 2
  } ]
}

Status Codes

Status Code

Description

200

Alarm policy modified.

400

Parameter verification failed.

500

System error.

Error Codes

See Error Codes.