Help Center/ Cloud Eye/ API Reference/ API V2/ Alarm Policies/ Modifying All Fields in an Alarm Policy
Updated on 2025-08-13 GMT+08:00

Modifying All Fields in an Alarm Policy

Function

This API is used to modify all fields in an alarm rule.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Tenant ID.

Constraints:

None

Value range:

Project ID, used to specify the project that an asset belongs to. You can query the assets of a project by project ID. You can obtain the project ID by calling an API or on the console. For details, see Obtaining a Project ID. The value must contain of 1 to 64 characters.

Default value:

None

alarm_id

Yes

String

Alarm rule ID.

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

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Definition

MIME type of the request body.

Constraints:

None

Value range:

The value can contain 1 to 64 characters.

Default value:

The default type is application/json; charset=UTF-8.

Default value:

application/json; charset=UTF-8

X-Auth-Token

Yes

String

Definition

User token.

Constraints:

None

Value range:

The value can contain 1 to 16,384 characters.

Default value:

None

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

policies

Yes

Array of UpdatePolicyReq objects

Policy information.

Table 4 UpdatePolicyReq

Parameter

Mandatory

Type

Description

metric_name

Yes

String

Metric name of a resource. The name must start with a letter and contain only digits, letters, 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.

extra_info

No

MetricExtraInfo object

If the policy does not contain additional information, extra_info does not need to be transferred.

period

Yes

Integer

Monitoring period of a metric, in seconds. The default value is 0. For an event alarm, set this parameter to 0. 1 indicates the original rollup period of a metric. For example, if the original rollup period of an RDS metric is 60s, its data point is calculated every 60 seconds. For details about the original rollup period of each cloud service metric, see Services Interconnected with Cloud Eye. 300 indicates that the metric rollup period is 5 minutes.

Value range:

0-86400

Enumeration values:

  • 0

  • 1

  • 300

  • 1200

  • 3600

  • 14400

  • 86400

filter

Yes

String

Aggregation mode. average: average value; variance: variance; min: minimum value; max: maximum value; sum: sum; tp99: 99 percentile; tp95: 95 percentile; tp90: 90 percentile

comparison_operator

Yes

String

Threshold symbol. The value can be >, <, >=, <=, =, !=, cycle_decrease, cycle_increase, or cycle_wave. cycle_decrease indicates the decrease compared with the last period, cycle_increase indicates the increase compared with the last period, and cycle_wave indicates the increase or decrease compared with the last period. All of them can be used in alarm rules for metrics. >, <, >=, <=, =, and != can be used for alarm rules for events.

value

No

Number

Alarm threshold If there is only one threshold, value and alarm_level are used in pairs. If there are both hierarchical_value and value, hierarchical_value is used. For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util to 80. For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util to 80 in Services Interconnected with Cloud Eye.

hierarchical_value

No

HierarchicalValue object

Multi-level alarm threshold. If there are both hierarchical_value and value, hierarchical_value prevails.

When you create or modify an alarm rule, you can set only one threshold in the following scenarios:

  1. The alarm type is Metric and the alarm policy is Trigger an alarm when all policies are met.

  2. The alarm type is Event.

unit

No

String

Data unit.

type

No

String

Alarm policy type. This API has been deprecated.

Regex Pattern: ^(auto)$

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.

suppress_duration

No

Integer

Alarm suppression time, in seconds. This parameter corresponds to the last field in 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 alarms are generated as long as the conditions are met. 300 indicates that an alarm is generated every 5 minutes as long as the alarm triggering conditions are met.

Value range:

0-86400

Enumeration values:

  • 0

  • 300

  • 600

  • 900

  • 1800

  • 3600

  • 10800

  • 21600

  • 43200

  • 86400

level

No

Integer

Alarm severity, which can be 1 (critical), ** 2** (major), 3 (minor), or 4 (informational). The default value is 2.

namespace

No

String

The namespace and dimension_name parameters are added to the product-level rule to specify the policy to which the product belongs. For details about the namespace of each service, see [Service Namespace] (ces_03_0059.xml).

Regex Pattern: ^((([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_)*\.([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_)*)|)$

dimension_name

No

String

The namespace and dimension_name parameters are added to the product-level rule to specify the policy to which the product belongs. Currently, a maximum of four dimensions are supported. For details about the metric dimension name of each service resource, see [Service dimension name] (ces_03_0059.xml). Example: instance_id in the single-dimension scenario; instance_id,disk in the multi-dimension scenario

Regex Pattern: ^(([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_|-|\.){0,31}(,([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_|-|\.){0,31}){0,3}|)$

Table 5 MetricExtraInfo

Parameter

Mandatory

Type

Description

origin_metric_name

Yes

String

Original metric name.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

metric_prefix

No

String

Metric name prefix.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

custom_proc_name

No

String

Name of a user process.

metric_type

No

String

Metric type.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

Table 6 HierarchicalValue

Parameter

Mandatory

Type

Description

critical

No

Double

Threshold for critical alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

major

No

Double

Threshold for major alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

minor

No

Double

Threshold for minor alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

info

No

Double

Threshold for informational alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

policies

Array of UpdatePolicyResp objects

Policy information.

Table 8 UpdatePolicyResp

Parameter

Type

Description

metric_name

String

Metric name of a resource. The name must start with a letter and contain only digits, letters, 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.

extra_info

MetricExtraInfoResp object

If the policy does not contain additional information, extra_info does not need to be transferred.

period

Integer

Monitoring period of a metric, in seconds. The default value is 0. For an event alarm, set this parameter to 0. 1 indicates the original rollup period of a metric. For example, if the original rollup period of an RDS metric is 60s, its data point is calculated every 60 seconds. For details about the original rollup period of each cloud service metric, see Services Interconnected with Cloud Eye. 300 indicates that the metric rollup period is 5 minutes.

Value range:

0-86400

Enumeration values:

  • 0

  • 1

  • 300

  • 1200

  • 3600

  • 14400

  • 86400

filter

String

Aggregation mode. average: average value; variance: variance; min: minimum value; max: maximum value; sum: sum; tp99: 99 percentile; tp95: 95 percentile; tp90: 90 percentile

comparison_operator

String

Threshold symbol. The value can be >, <, >=, <=, =, !=, cycle_decrease, cycle_increase, or cycle_wave. cycle_decrease indicates the decrease compared with the last period, cycle_increase indicates the increase compared with the last period, and cycle_wave indicates the increase or decrease compared with the last period. All of them can be used in alarm rules for metrics. >, <, >=, <=, =, and != can be used for alarm rules for events.

value

Number

Alarm threshold If there is only one threshold, value and alarm_level are used in pairs. If there are both hierarchical_value and value, hierarchical_value is used. For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util to 80. For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util to 80 in Services Interconnected with Cloud Eye.

hierarchical_value

HierarchicalValueResp object

Multi-level alarm threshold. If there are both hierarchical_value and value, hierarchical_value prevails.

When you create or modify an alarm rule, you can set only one threshold in the following scenarios:

  1. The alarm type is Metric and the alarm policy is Trigger an alarm when all policies are met.

  2. The alarm type is Event.

unit

String

Data unit.

type

String

Alarm policy type. This API has been deprecated.

Regex Pattern: ^(auto)$

count

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.

suppress_duration

Integer

Alarm suppression time, in seconds. This parameter corresponds to the last field in 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 alarms are generated as long as the conditions are met. 300 indicates that an alarm is generated every 5 minutes as long as the alarm triggering conditions are met.

Value range:

0-86400

Enumeration values:

  • 0

  • 300

  • 600

  • 900

  • 1800

  • 3600

  • 10800

  • 21600

  • 43200

  • 86400

level

Integer

Alarm severity, which can be 1 (critical), ** 2** (major), 3 (minor), or 4 (informational). The default value is 2.

namespace

String

The namespace and dimension_name parameters are added to the product-level rule to specify the policy to which the product belongs. For details about the namespace of each service,see Services Interconnected with Cloud Eye.

Regex Pattern: ^((([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_)*\.([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_)*)|)$

dimension_name

String

The namespace and dimension_name parameters are added to the product-level rule to specify the policy to which the product belongs. Currently, a maximum of four dimensions are supported. For details about the metric dimension name of each service resource, see Services Interconnected with Cloud Eye. Example: instance_id in the single-dimension scenario; instance_id,disk in the multi-dimension scenario

Regex Pattern: ^(([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_|-|\.){0,31}(,([a-z]|[A-Z]){1}([a-z]|[A-Z]|[0-9]|_|-|\.){0,31}){0,3}|)$

Table 9 MetricExtraInfoResp

Parameter

Type

Description

origin_metric_name

String

Original metric name.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

metric_prefix

String

Metric name prefix.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

custom_proc_name

String

Name of a user process.

metric_type

String

Metric type.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

Table 10 HierarchicalValueResp

Parameter

Type

Description

critical

Double

Threshold for critical alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

major

Double

Threshold for major alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

minor

Double

Threshold for minor alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

info

Double

Threshold for informational alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

Status code: 400

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Example Requests

Modify an alarm policy whose metric name is disk_device_read_bytes_rate.

{
  "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

Modification succeeded.

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

Status Codes

Status Code

Description

200

Modification succeeded.

400

Parameter verification failed.

500

Internal system error.

Error Codes

See Error Codes.