Updated on 2024-05-16 GMT+08:00

Querying Alarm Records

Function

This API is used to query alarm records.

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}/alarm-histories

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

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

alarm_id

No

String

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

Minimum: 24

Maximum: 24

name

No

String

Specifies the alarm rule name.

Minimum: 0

Maximum: 128

status

No

String

Specifies the alarm rule status. The value can be ok, alarm, or invalid.

Minimum: 0

Maximum: 64

Regex Pattern: ^(ok|alarm|invalid)$

level

No

Integer

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

Minimum: 1

Maximum: 4

namespace

No

String

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

Minimum: 3

Maximum: 32

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

Minimum: 0

Maximum: 2048

from

No

String

Specifies the start time for querying alarm records, for example, 2022-02-10T10:05:46+08:00.

Minimum: 0

Maximum: 64

to

No

String

Specifies the end time for querying alarm records, for example, 2022-02-10T10:05:47+08:00.

Minimum: 0

Maximum: 64

offset

No

Integer

Specifies the pagination offset.

Minimum: 0

Maximum: 999

Default: 0

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

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

Yes

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

Yes

String

Specifies the user token.

Minimum: 1

Maximum: 16384

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

alarm_histories

Array of AlarmHistoryItemV2 objects

Specifies the alarm records.

Array Length: 0 - 100

count

Integer

Specifies the total number of alarm records.

Minimum: 0

Maximum: 2147483647

Table 5 AlarmHistoryItemV2

Parameter

Type

Description

record_id

String

Specifies the alarm record ID.

Minimum: 24

Maximum: 24

alarm_id

String

Specifies the alarm rule ID, for example, al1603131199286dzxpqK3Ez.

Minimum: 24

Maximum: 24

name

String

Specifies the alarm rule name, for example, alarm-test01.

Minimum: 1

Maximum: 128

status

String

Specifies the status of an alarm record. The value can be ok, alarm, or invalid.

Enumeration values:

  • ok
  • alarm
  • invalid

level

Integer

Specifies the alarm severity of alarm records. The value can be 1 (critical), 2 (major), 3 (minor), or 4 (informational).

Enumeration values:

  • 1
  • 2
  • 3
  • 4

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

action_enabled

Boolean

Specifies whether to send a notification. The value can be true or false.

begin_time

String

Specifies when an alarm record is generated (UTC time).

end_time

String

Specifies when an alarm record becomes invalid (UTC time).

metric

Metric object

Specifies the metric information.

condition

AlarmCondition object

Specifies the conditions for triggering an alarm.

additional_info

AdditionalInfo object

Specifies the additional field of an alarm record, which applies only to alarm records generated in event monitoring scenarios.

alarm_actions

Array of Notification objects

Specifies the action to be triggered by an alarm. The structure is as follows: { "type": "notification", "notification_list": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"] }. type can be notification, autoscaling, or notification_list. notification indicates that a notification action will be triggered. autoscaling indicates that a scaling action will be triggered. notification_list indicates that when the alarm rule status changes, Cloud Eye will notify users in the notification list.

Array Length: 0 - 10

ok_actions

Array of Notification objects

Specifies the action to be triggered after an alarm is cleared. The structure is as follows: { "type": "notification", "notification_list": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"] }. type can be notification, autoscaling, or notification_list. notification indicates that a notification action will be triggered. notification_list indicates that when the alarm rule status changes, Cloud Eye will notify users in the notification list.

Array Length: 0 - 10

data_points

Array of DataPointInfo objects

Specifies the time when the resource monitoring data is reported and the monitoring data in the alarm record.

Array Length: 0 - 2147483647

Table 6 Metric

Parameter

Type

Description

namespace

String

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

Minimum: 3

Maximum: 32

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.

Minimum: 1

Maximum: 64

dimensions

Array of Dimension objects

Specifies the metric dimension. A maximum of four dimensions can be added.

Array Length: 0 - 4

Table 7 Dimension

Parameter

Type

Description

name

String

Specifies the dimension of a resource. For example, the dimension of an Elastic Cloud Server (ECS) can be instance_id. A maximum of four dimensions are supported. For the metric dimension of each resource, see Service metric dimension.

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

value

String

Specifies the value of a resource dimension, which is the resource ID, for example, 4270ff17-aba3-4138-89fa-820594c39755.

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

Table 8 AlarmCondition

Parameter

Type

Description

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.

Enumeration values:

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

filter

String

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

Minimum: 1

Maximum: 15

Regex Pattern: ^(average|min|max|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.

Minimum: 1

Maximum: 10

Regex Pattern: ^(>|<|>=|<=|=|!=|cycle_decrease|cycle_increase|cycle_wave)$

value

Double

Specifies the 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 Elastic Cloud Server (ECS) cpu_util to 80.

Minimum: 0

Maximum: 1.174271E108

unit

String

Specifies the data unit. Enter up to 32 characters.

Minimum: 0

Maximum: 32

count

Integer

Specifies the number of times that the alarm triggering conditions are met.

Minimum: 1

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

Enumeration values:

  • 0
  • 300
  • 600
  • 900
  • 1800
  • 3600
  • 10800
  • 21600
  • 43200

Regex Pattern: ^(0|300|600|900|1800|3600|10800|21600|43200|86400)$

Table 9 AdditionalInfo

Parameter

Type

Description

resource_id

String

Specifies the resource ID corresponding to the alarm record, for example, 22d98f6c-16d2-4c2d-b424-50e79d82838f.

Minimum: 0

Maximum: 128

resource_name

String

Specifies the resource name corresponding to the alarm record, for example, ECS-Test01.

Minimum: 0

Maximum: 128

event_id

String

Specifies the ID of the event in the alarm record, for example, ev16031292300990kKN8p17J.

Minimum: 24

Maximum: 24

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

Table 11 DataPointInfo

Parameter

Type

Description

time

String

Specifies the UTC time when the resource monitoring data of the alarm record is reported.

Minimum: 1

Maximum: 64

value

Double

Specifies the resource monitoring data of the alarm record at the time point, for example, 7.019.

Minimum: 0

Maximum: 1.7976931348623157E308

Status code: 400

Table 12 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 13 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 records whose alarm_name is alarm-test01, and from and to are 2022-02-10T10:05:46+08:00

/v2/{project_id}/alarm-histories?limit=10&offset=0&from=2022-02-10T10:05:46+08:00&to=2022-02-10T12:05:46+08:00&alarm_name=alarm-test01

Example Responses

Status code: 200

Query succeeded.

{
  "alarm_histories" : [ {
    "alarm_id" : "al1604473987569z6n6nkpm1",
    "record_id" : "ah1655717086704DEnBrJ999",
    "name" : "TC_CES_FunctionBaseline_Alarm_008",
    "metric" : {
      "namespace" : "SYS.VPC",
      "dimensions" : [ {
        "name" : "bandwidth_id",
        "value" : "79a9cc0c-f626-4f15-bf99-a1f184107f88"
      } ],
      "metric_name" : "downstream_bandwidth"
    },
    "condition" : {
      "period" : 1,
      "filter" : "average",
      "comparison_operator" : ">=",
      "value" : 0,
      "count" : 3,
      "suppress_duration" : 3600
    },
    "level" : 2,
    "type" : "ALL_INSTANCE",
    "begin_time" : "2024-02-11T05:48:08+08:00",
    "end_time" : "2024-02-11T08:48:08+08:00",
    "action_enabled" : false,
    "alarm_actions" : [ ],
    "ok_actions" : [ ],
    "status" : "alarm",
    "data_points" : [ {
      "time" : "2022-06-22T16:38:02+08:00",
      "value" : 873.1507798960139
    }, {
      "time" : "2022-06-22T16:28:02+08:00",
      "value" : 883.1507798960139
    }, {
      "time" : "2022-06-22T16:18:02+08:00",
      "value" : 873.4
    } ],
    "additional_info" : {
      "resource_id" : "",
      "resource_name" : "",
      "event_id" : ""
    }
  } ],
  "count" : 103
}

Status Codes

Status Code

Description

200

Query succeeded.

400

Failed to verify parameters.

500

Internal system error.

Error Codes

See Error Codes.