Updated on 2024-04-30 GMT+08:00

Querying Alarm Rules

Function

This API is used to query alarm rules.

Debugging

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

URI

GET /v2/{project_id}/alarms

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the tenant ID.

Minimum: 1

Maximum: 64

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

alarm_id

No

String

Specifies the alarm rule ID.

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

name

No

String

Specifies the name of an alarm rule. The name can contain 1 to 128 characters, including only letters, digits, underscores (_), and hyphens (-).

Minimum: 1

Maximum: 128

Regex Pattern: ^([\u4E00-\u9FFF]|[a-z]|[A-Z]|[0-9]|_|-)+$

namespace

No

String

Specifies the namespace of a service. For details about the namespace of each service, see Namespace.

Maximum: 32

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

resource_id

No

String

Specifies the ID of a resource in an alarm rule. If the resource has multiple dimensions, the resource IDs are sorted in ascending alphabetical order and separated by commas (,). For example, if the monitored resource is an ECS disk, the dimension name disk is placed before the dimension name instance_id in alphabetical order. In this case, the resource ID must be combined as Disk ID,Instance ID.

Maximum: 700

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

enterprise_project_id

No

String

Specifies the enterprise project ID.

Regex Pattern: ^((([a-z]|[0-9]){8}-([a-z]|[0-9]){4}-([a-z]|[0-9]){4}-([a-z]|[0-9]){4}-([a-z]|[0-9]){12})|0)$

offset

No

Integer

Specifies the pagination offset.

Minimum: 0

Maximum: 10000

Default: 0

Regex Pattern: ^([0]|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|10000)$

limit

No

Integer

Specifies the number of records that will be displayed on each page.

Minimum: 1

Maximum: 100

Default: 10

Regex Pattern: ^([1-9]|[1-9][0-9]|100)$

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

No

String

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

Default: application/json; charset=UTF-8

Minimum: 1

Maximum: 64

X-Auth-Token

No

String

Specifies the user token.

Minimum: 1

Maximum: 16384

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

alarms

Array of alarms objects

Specifies the alarm rule list.

Array Length: 1 - 100

count

Integer

Specifies the total number of alarm rules.

Minimum: 0

Maximum: 10000

Table 5 alarms

Parameter

Type

Description

alarm_id

String

Specifies the ID of an alarm rule, which starts with al and is followed by 22 characters, including letters and digits.

name

String

Specifies the name of an alarm rule. The name can contain 1 to 128 characters, including only letters, digits, underscores (_), and hyphens (-).

description

String

Provides supplementary information about an alarm rule. The description can contain 0 to 256 characters.

namespace

String

Specifies the namespace of a service. For details about the namespace of each service, see Namespace.

policies

Array of Policy objects

Specifies the alarm policy.

Array Length: 1 - 100

resources

Array of ResourcesInListResp objects

Specifies the resource list. Associated resources can be obtained by calling the API for querying resources in an alarm rule.

Array Length: 1 - 3000

type

String

Specifies the alarm rule type. ALL_INSTANCE indicates alarm rules for metrics of all resources. RESOURCE_GROUP indicates alarm rules for metrics of resources in a resource group. MULTI_INSTANCE indicates alarm rules for metrics of specified resources. EVENT.SYS indicates alarm rules for system events. EVENT.CUSTOM indicates alarm rules for custom events. DNSHealthCheck indicates alarm rules for health checks.

Enumeration values:

  • EVENT.SYS
  • EVENT.CUSTOM
  • DNSHealthCheck
  • RESOURCE_GROUP
  • MULTI_INSTANCE
  • ALL_INSTANCE

enabled

Boolean

Specifies whether to generate alarms when the alarm triggering conditions are met.

notification_enabled

Boolean

Specifies whether to enable the alarm notification.

alarm_notifications

Array of Notification objects

Specifies the action to be triggered by an alarm.

ok_notifications

Array of Notification objects

Specifies the action to be triggered after an alarm is cleared.

notification_begin_time

String

Specifies the time when the alarm notification was enabled.

notification_end_time

String

Specifies the time when the alarm notification was disabled.

enterprise_project_id

String

Specifies the enterprise project ID.

alarm_template_id

String

Specifies the ID of an alarm template associated with an alarm rule. If this parameter is specified, the policy associated with the alarm rule changes accordingly with the alarm template policy.

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 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.

period

Integer

Specifies the rollup 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.

Minimum: 0

Maximum: 86400

Enumeration values:

  • 0
  • 1
  • 300
  • 1200
  • 3600
  • 14400
  • 86400

filter

String

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

comparison_operator

String

Specifies the 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

Specifies the threshold.

unit

String

Specifies the metric unit.

count

Integer

Specifies the number of times that the alarm triggering conditions are met. 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

Specifies the 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.

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).

Table 7 ResourcesInListResp

Parameter

Type

Description

resource_group_id

String

Specifies the resource group ID. This parameter is available when the monitoring scope is resource groups.

Regex Pattern: ^rg([a-z]|[A-Z]|[0-9]){22}$

resource_group_name

String

Specifies the resource group name. This parameter is available when the monitoring scope is resource groups.

Minimum: 1

Maximum: 128

dimensions

Array of MetricDimension objects

Specifies the dimension.

Array Length: 0 - 10000

Table 8 MetricDimension

Parameter

Type

Description

name

String

Specifies the name of a metric dimension.

Minimum: 1

Maximum: 32

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

value

String

Specifies the value of a metric dimension.

Minimum: 0

Maximum: 256

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

Table 9 Notification

Parameter

Type

Description

type

String

Specifies the notification type. notification indicates that notifications are sent through Simple Message Notification (SMN).

Regex Pattern: ^(notification|autoscaling|ecsRecovery|contact|contactGroup|iecAction)$

notification_list

Array of strings

Specifies the list of objects to be notified if the alarm status changes. The value of topicUrn can be obtained from SMN. For details, see section "Querying Topics". When type is set to notification, notification_list cannot be left blank. Note: If alarm_action_enabled is set to true, alarm_actions, ok_actions, or both of them must be specified. If alarm_actions and ok_actions coexist, their notification_list values must be the same.

Array Length: 0 - 20

Status code: 400

Table 10 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 11 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

Querying alarm rules

/v2/{project_id}/alarms?offset=0&limit=10

Example Responses

Status code: 200

Query succeeded.

{
  "alarms" : [ {
    "alarm_id" : "al16558829757444BVVxr999",
    "name" : "alarm01",
    "description" : "",
    "namespace" : "SYS.ECS",
    "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
    } ],
    "resources" : [ {
      "dimensions" : [ {
        "name" : "disk_name"
      } ]
    } ],
    "type" : "ALL_INSTANCE",
    "enabled" : true,
    "notification_enabled" : true,
    "alarm_notifications" : [ {
      "type" : "notification",
      "notification_list" : [ "urn:smn:xxx:xxx70e7359:topic_xxx" ]
    } ],
    "ok_notifications" : [ {
      "type" : "notification",
      "notification_list" : [ "urn:smn:xxx:xxx70e7359:topic_xxx" ]
    } ],
    "notification_begin_time" : "00:00",
    "notification_end_time" : "23:59",
    "enterprise_project_id" : 0
  } ]
}

Status Codes

Status Code

Description

200

Query succeeded.

400

Failed to verify parameters.

500

Internal system error.

Error Codes

See Error Codes.