Querying Alarm Rules for One Service in One-Click Monitoring

Function

This API is used to query alarm rules for one service in one-click monitoring.

URI

GET /v2/{project_id}/one-click-alarms/{one_click_alarm_id}/alarms

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}$

one_click_alarm_id

Yes

String

One-click monitoring ID.

Minimum: 1

Maximum: 64

Regular expression matching: ^([a-z]|[A-Z]|[0-9]){1,64}$

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

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

Default: application/json; charset=UTF-8

Minimum: 1

Maximum: 64

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

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

alarms

Array of alarms objects

Alarm rule list.

Array length: 1 to 100

Table 4 alarms

Parameter

Type

Description

alarm_id

String

ID of an alarm rule, which starts with al and is followed by 22 characters of letters, digits, or a combination of both.

name

String

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

description

String

Alarm rule description. The value can contain 0 to 256 characters.

namespace

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

policies

Array of Policy objects

Alarm policies.

Array length: 1 to 100

resources

Array of Resources object

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

Array length: 1 to 3000

type

String

Alarm rule type.

The value can be:

  • ALL_INSTANCE: alarms for all resources
  • RESOURCE_GROUP: alarms for resource groups
  • MULTI_INSTANCE: alarms for specified resources
  • EVENT.SYS: system event alarms
  • EVENT.CUSTOM: custom event alarms

enabled

Boolean

Whether to generate alarms when the alarm triggering conditions are met.

notification_enabled

Boolean

Whether to enable alarm notifications.

alarm_notifications

Array of Notification objects

Action to be triggered by the alarm. Array length: 0 to 10

ok_notifications

Array of Notification objects

Action to be triggered after an alarm is cleared. Array length: 0 to 10

notification_begin_time

String

Time when the alarm notification was enabled. Example: 09:00

Regular expression matching: ^([1][0-9]|2[0-3]):([0-5][0-9])$

notification_end_time

String

Time when the alarm notification was disabled. Example: 12:00

Regular expression matching: ^([1][0-9]|2[0-3]):([0-5][0-9])$

Table 5 Policy

Parameter

Type

Description

alarm_policy_id

String

Alarm policy ID.

Regular expression matching: ^([a-z]|[A-Z]|[0-9]|-)+$

metric_name

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

Integer

How often to generate an alarm, in seconds. 1 indicates that alarms are generated based on raw data. When alarm_type is EVENT.SYS or EVENT.CUSTOM, the value may be 0.

The value can be:

  • 0

  • 1

  • 300

  • 1200

  • 3600

  • 14400

  • 86400

filter

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

String

Operator of an alarm threshold.

Regular expression matching: ^(>|<|>=|<=|=|!=)$

value

Number

Alarm threshold. Supported range: 0 to Number. MAX_VALUE (1.7976931348623157e+108) For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util to 80.

Minimum: 0

Maximum: 1.7976931348623157e+108

unit

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

Integer

Number of times that the alarm triggering conditions are met. Value range: 1 to 180

suppress_duration

Integer

Suppression period, in seconds. 0 indicates that only one alarm is generated.

The value can be:

  • 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 (warning).

enabled

Boolean

Whether to enable the function.

Table 6 Resources

Parameter

Type

Description

resource_group_id

String

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

Regular expression matching: ^rg([a-z]|[A-Z]|[0-9]){22}$

resource_group_name

String

Resource group name. This parameter is available when the monitoring scope is set to Resource groups.

Minimum: 1

Maximum: 128

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

dimensions

Array of Dimensions objects

Dimension information.

Array length: 0 to 10000

Table 7 Dimensions

Parameter

Description

name

Metric dimension name.

Minimum: 1

Maximum: 32

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

Table 8 Notification

Parameter

Type

Description

type

String

Notification type.

The value can be:

notification: topic subscriptions. Notifications are sent using SMN topics.

contact: cloud account contacts. Notifications are sent using the mobile number and email address registered for your account.

notification_list

Array of strings

List of objects to be notified of alarm status changes. The value of topicUrn can be obtained from SMN. For details, see section Querying Topics. If type is set to notification, the value of notificationList cannot be empty. If type is set to autoscaling, the value of notificationList must be empty. If you set alarm_action_enabled to true, you must specify either alarm_actions or ok_actions. If alarm_actions and ok_actions coexist, their notificationList must be the same.

Array length: 0 to 20

Status code: 400

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

Status code: 401

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

Query alarm rules of a service in one-click monitoring.

GET /v2/{project_id}/one-click-alarms/{one_click_alarm_id}/alarms

Example Responses

Status code: 200

OK

{
  "alarms" : [ {
    "alarm_id" : "al123232232341232132",
    "name" : "alarm1",
    "description" : "hello world",
    "namespace" : "SYS.ECS",
    "policies" : [ {
      "alarm_policy_id" : "alxdxxxdsw12321321",
      "metric_name" : "cpu_util",
      "period" : 0,
      "filter" : "max",
      "comparison_operator" : "",
      "value" : 1.7976931348623156E108,
      "unit" : "%",
      "count" : 100,
      "suppress_duration" : 0,
      "level" : 2,
      "enabled" : true
    } ],
    "resources" : [ {
      "dimensions" : [ {
        "name" : "string",
        "value" : "string"
      } ]
    } ],
    "type" : "EVENT.SYS",
    "enabled" : true,
    "notification_enabled" : true,
    "alarm_notifications" : [ {
      "type" : "notification",
      "notification_list" : [ "urn:smn:123" ]
    } ],
    "ok_notifications" : [ {
      "type" : "notification",
      "notification_list" : [ "urn:smn:123" ]
    } ],
    "notification_begin_time" : "00:00",
    "notification_end_time" : "23:59"
  } ]
}

Status Codes

Status Code

Description

200

OK

400

Parameter verification failed.

401

Authentication failed.

403

Authentication failed.

500

Failed to complete the request because of an internal server error.

Error Codes

See Error Codes.