Updated on 2025-09-09 GMT+08:00

Querying Alarm Rules

Function

This API is used to query alarm rules. You can specify the paging parameters to limit the number of query results displayed on a page. You can also set the sorting order of query results.

For API V1, only an alarm rule can be configured for a single resource. You are advised to use Querying Alarm Rules (Recommended) to work with the console.

Debugging

You can debug the API in API Explorer which supports automatic authentication. API Explorer can automatically generate and debug example SDK code.

URI

GET /V1.0/{project_id}/alarms

  • Parameter description
    Table 1 Parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Definition

    Project ID. It is 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 from the API or console. For details about how to obtain the project ID, see Obtaining a Project ID.

    Constraints

    N/A

    Range

    1 to 64 characters

    Default Value

    N/A

    Table 2 Query parameter description

    Parameter

    Mandatory

    Type

    Description

    start

    No

    String

    Definition

    Pagination start value. The value is alarm_id.

    Constraints

    N/A

    Range

    The value starts with al and is followed by 22 characters of letters, digits, or a combination of both. The value can contain a total of 24 characters.

    Default Value

    N/A

    limit

    No

    Integer

    Definition

    Number of records that can be returned.

    Constraints

    N/A

    Range

    (0,100]

    Default Value

    100

    order

    No

    String

    Definition

    Result sorting method, which is sorted by timestamp.

    Constraints

    N/A

    Range

    The value can be:

    • asc: The query results are displayed in the ascending order.
    • desc: The query results are displayed in the descending order.

    Default Value

    desc

  • Example
    Request example 1: Query the current alarm rule list.
    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/alarms

    Request example 2: Query the alarm rule list. Start by setting alarm_id to al1441967036681YkazZ0deN and retain 10 records in the descending order of time stamps.
    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/alarms?start=al1441967036681YkazZ0deN&limit=10&order=desc

Request

None

Response

  • Response parameters
    Table 3 Parameter description

    Parameter

    Type

    Description

    metric_alarms

    Array of objects

    Definition

    List of alarm objects.

    For details, see Table 4.

    meta_data

    Object

    Definition

    Metadata of query results, including the pagination information.

    For details, see Table 11.

    Table 4 metric_alarms data structure description

    Parameter

    Type

    Description

    alarm_name

    String

    Definition

    Alarm name.

    Range

    N/A

    alarm_description

    String

    Definition

    Provides supplementary information about the alarm rule.

    Range

    N/A

    metric

    Object

    Definition

    Alarm metrics.

    For details, see Table 5.

    condition

    Object

    Definition

    Alarm triggering condition.

    For details, see Table 10.

    alarm_enabled

    Boolean

    Definition

    Whether to enable the alarm rule.

    Range

    A boolean value.

    • true: enable

    • false: disable

    alarm_level

    Integer

    Definition

    Alarm severity.

    Range

    The value can be 1 (critical), 2 (major), 3 (minor), or 4 (warning).

    alarm_action_enabled

    Boolean

    Definition

    Whether to enable the action triggered by the alarm.

    Range

    A boolean value.

    • true: enable

    • false: disable

    alarm_actions

    Array of objects

    Definition

    Action to be triggered by the alarm.

    For details, see Table 7.

    ok_actions

    Array of objects

    Definition

    Action to be triggered after an alarm is cleared.

    For details, see Table 8.

    insufficientdata_actions

    Array of objects

    Definition

    Action triggered by data insufficiency.

    For details, see Table 9.

    alarm_action_begin_time

    String

    Definition

    Time when an alarm rule is applied. Notifications are sent only within the validity period of the alarm rule.

    For example, if alarm_action_begin_time is set to 08:00 and alarm_action_end_time is set to 20:00, notifications are sent only from 08:00 to 20:00.

    Range

    The value allows 1 to 64 characters and can contain only digits and colons (:).

    alarm_action_end_time

    String

    Definition

    Time when an alarm rule becomes invalid.

    For example, if alarm_action_begin_time is set to 08:00 and alarm_action_end_time is set to 20:00, notifications are sent only from 08:00 to 20:00.

    Range

    The value allows 1 to 64 characters and can contain only digits and colons (:).

    alarm_type

    String

    Definition

    Alarm rule type.

    Range

    • EVENT.SYS: The alarm rule is created for system events. EVENT.CUSTOM: The alarm rule is created for custom events.
    • RESOURCE_GROUP: The alarm rule is created for resource groups.
    • MULTI_INSTANCE: The alarm rule is created for specific resources.

    alarm_id

    String

    Definition

    Alarm rule ID.

    Range

    The value starts with al and is followed by 22 characters of letters, digits, or a combination of both.

    update_time

    Long

    Definition

    Time when the alarm status changed. The value is a UNIX timestamp, in ms.

    Range

    N/A

    alarm_state

    String

    Definition

    Alarm status.

    Range

    • ok: The alarm status is normal.
    • alarm: An alarm is generated.
    • insufficient_data: The required data is insufficient.

    enterprise_project_id

    String

    Definition

    Enterprise project ID.

    Range

    The value can only contain lowercase letters, digits, hyphens (-), and underscores (_). It allows 36 characters. The value can be 0 (default enterprise project ID) or all_granted_eps (all enterprise project IDs).

    Table 5 metric data structure description

    Parameter

    Type

    Description

    namespace

    String

    Definition

    Namespace of the queried service. For details, see Services Interconnected with Cloud Eye.

    Range

    N/A

    dimensions

    Array of objects

    Definition

    List of metric dimensions.

    For details, see Table 6.

    metric_name

    String

    Definition

    Metric ID. For example, metric_name of ECS CPU usage is cpu_util. For details about the metrics of each service, see Services Interconnected with Cloud Eye.

    Range

    N/A

    resource_group_id

    String

    Definition

    ID of the resource group selected during the alarm rule creation, for example, rg1603786526428bWbVmk4rP.

    Range

    N/A

    resource_group_name

    String

    Definition

    Name of the resource group selected during the alarm rule creation, for example, Resource-Group-ECS-01.

    Range

    N/A

    Table 6 dimensions data structure description

    Parameter

    Type

    Description

    name

    String

    Definition

    Monitoring dimension name. For example, the ECS dimension is instance_id. For details about the dimension of each service, see the key column in Services Interconnected with Cloud Eye.

    Range

    N/A

    value

    String

    Definition

    Dimension value, for example, an ECS ID.

    Range

    Enter 1 to 256 characters.

    Table 7 alarm_actions data structure description

    Parameter

    Type

    Description

    type

    String

    Definition

    Alarm notification type.

    Range
    • notification: A notification will be sent.
    • autoscaling: A scaling action will be triggered.

    notificationList

    Array of strings

    Definition

    List of objects to be notified of alarm status changes.

    NOTE:

    The IDs in the list are strings.

    Table 8 ok_actions data structure description

    Parameter

    Type

    Description

    type

    String

    Definition

    Notification type when an alarm is cleared.

    Range
    • notification: A notification will be sent.
    • autoscaling: A scaling action will be triggered.

    notificationList

    Array of strings

    Definition

    List of IDs of objects to be notified of alarm status changes.

    NOTE:

    The IDs in the list are strings.

    Table 9 insufficientdata_actions data structure description

    Parameter

    Type

    Description

    type

    String

    Definition

    Type of the alarm notification triggered by insufficient data.

    Range

    notification

    notificationList

    Array of strings

    Definition

    IDs of the notified objects when an alarm notification is triggered due to insufficient data.

    Table 10 condition data structure description

    Parameter

    Type

    Description

    period

    Integer

    Definition

    Interval (seconds) for checking whether the alarm rule conditions are met.

    Range

    The value can be:

    • 0: triggered immediately (only for event scenarios).

    • 1: original metric period. For example, if the original period of an RDS metric is 60s, the metric data is collected and calculated every 60s.

    • 300: The metric data is collected and calculated every 5 minutes.

    • 1200: The metric data is collected and calculated every 20 minutes.

    • 3600: The metric data is collected and calculated every hour.

    • 14400: The metric data is collected and calculated every 4 hours.

    • 86400: The metric data is collected and calculated every day.

    filter

    String

    Definition

    Data aggregation method.

    Range

    • average: average value of metric data within an aggregation period.
    • max: maximum value of metric data in an aggregation period.
    • min: Cloud Eye calculates the minimum value of metric data within a rollup period.
    • sum: sum of metric data within an aggregation period.
    • variance: variance value of metric data within an aggregation period.

    comparison_operator

    String

    Definition

    Operator of an alarm threshold.

    Range

    >, =, <, >=, <=, or !=

    value

    Double

    Definition

    Alarm threshold.

    For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util in Services Interconnected with Cloud Eye to 80.

    Range

    [0, Number.MAX_VALUE], where Number.MAX_VALUE indicates 1.7976931348623157e+108

    unit

    String

    Definition

    Data unit.

    Range

    0 to 32 characters

    count

    Integer

    Definition

    Number of consecutive times that an alarm is triggered.

    Range

    [1, 5]

    suppress_duration

    Integer

    Definition

    Interval for triggering an alarm if the alarm persists.

    Range

    The value can be:

    • 0: The alarm is triggered only once.
    • 300: An alarm is triggered every 5 minutes.
    • 600: An alarm is triggered every 10 minutes.
    • 900: An alarm is triggered every 15 minutes.
    • 1800: An alarm is triggered every 30 minutes.
    • 3600: An alarm is triggered every hour.
    • 10800: An alarm is triggered every 3 hours.
    • 21600: An alarm is triggered every 6 hours.
    • 43200: An alarm is triggered every 12 hours.
    • 86400: An alarm is triggered every day.
    Table 11 meta_data data structure description

    Parameter

    Type

    Description

    count

    Integer

    Definition

    Number of returned records.

    Range

    N/A

    marker

    String

    Definition

    Pagination marker.

    For example, you have queried 10 records this time and alarm_id of the tenth record is 1441967036681YkazZ0deN. In your next query, if start is set to al1441967036681YkazZ0deN, you can start your query from the next alarm rule ID of al1441967036681YkazZ0deN.

    Range

    N/A

    total

    Integer

    Definition

    Total number of query results.

    Range

    N/A

  • Example response
    {
        "metric_alarms": [
            {
                "alarm_name": "alarm-ttttttt",
                "alarm_description": "",
                "metric": {
                    "namespace": "SYS.ECS",
                    "dimensions": [
                        {
                            "name": "instance_id",
                            "value": "07814c0e-59a1-4fcd-a6fb-56f2f6923046"
                        }
                    ],
                    "metric_name": "cpu_util"
                },
                "condition": {
                    "period": 300,
                    "filter": "average",
                    "comparison_operator": ">=",
                    "value": 0,
                    "unit": "%",
                    "count": 3                
                },
                "alarm_enabled": true,
                "alarm_level": 2,
                "alarm_action_enabled": false,
                "alarm_id": "al15330507498596W7vmlGKL",
                "update_time": 1533050749992,
                "alarm_state": "alarm"
            },
            {
                "alarm_name": "alarm-m5rwxxxxxxx",
                "alarm_description": "",
                "metric": {
                    "namespace": "SYS.ECS",
                    "dimensions": [
                        {
                            "name": "instance_id",
                            "value": "30f3858d-4377-4514-9081-be5bdbf1392e"
                        }
                    ],
                    "metric_name": "network_incoming_bytes_aggregate_rate"
                },
                "condition": {
                    "period": 300,
                    "filter": "average",
                    "comparison_operator": ">=",
                    "value": 12,
                    "unit": "Byte/s",
                    "count": 3,
                    "suppress_duration": 1800               
                },
                "alarm_enabled": true,
                "alarm_level": 2,
                "alarm_action_enabled": true,
                "alarm_actions": [
                    {
                        "type": "notification",
                        "notificationList": [
                            "urn:smn:region:68438a86d98e427e907e0097b7e35d48:test0315"
                        ]
                    }
                ],
                "ok_actions": [
                    {
                        "type": "notification",
                        "notificationList": [
                            "urn:smn:region:68438a86d98e427e907e0097b7e35d48:test0315"
                        ]
                    }
                ], 
                "alarm_id": "al1533031226533nKJexAlbq",
                "update_time": 1533204036276,
                "alarm_state": "ok"
            }
        ],
        "meta_data": {
            "count": 2,
            "marker": "al1533031226533nKJexAlbq",
            "total": 389
        }
    }

Returned Values

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    The authentication information is not provided or is incorrect.

    403 Forbidden

    Access to the requested page is forbidden.

    408 Request Timeout

    The request timed out.

    429 Too Many Requests

    Concurrent requests are excessive.

    500 Internal Server Error

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

    503 Service Unavailable

    The service is currently unavailable.

Error Codes

See Error Codes.