Help Center/ Cloud Eye/ API Reference/ API V1/ Alarm Rules/ Querying the Alarm History of an Alarm Rule
Updated on 2024-02-23 GMT+08:00

Querying the Alarm History of an Alarm Rule

Function

This API is used to query the alarm history of an alarm rule based on the alarm rule ID.

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

  • Parameter description
    Table 1 Parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID.

    For details about how to obtain the project ID, see Obtaining a Project ID.

    group_id

    No

    Specifies the resource group ID, for example, rg1603107497873DK4O2pXbn.

    alarm_id

    No

    Specifies the alarm rule ID, for example, al1603088932912v98rGl1al.

    alarm_name

    No

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

    alarm_status

    No

    Specifies the alarm status, which can be ok, alarm, or insufficient_data.

    alarm_level

    No

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

    namespace

    No

    Specifies the resource namespace. For example, the ECS namespace is SYS.ECS. To view the namespace of each service, see Services Interconnected with Cloud Eye.

    from

    No

    Specifies the time from when you want to query the alarm history. The time is a UNIX timestamp (ms), for example, 1602501480905. If you do not configure from or to, to is the current time by default, and from is the timestamp of seven days earlier than the current time.

    to

    No

    Specifies when you want your alarm history query to end. The time is a UNIX timestamp (ms). The value of from can be to or smaller. If you do not configure from or to, to is the current time by default, and from is the timestamp of seven days earlier than the current time.

    start

    No

    Specifies the start value of pagination. The value is an integer. The default value is 0.

    limit

    No

    Specifies the maximum number of records that can be queried at a time. Supported range: 1 to 100 (default)

  • Example
    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/alarm-histories?limit=10&start=0&from=1602494921346&to=1603099721346&alarm_name=alarm-test01

Request

None

Response

  • Response parameters

    Parameter

    Type

    Mandatory

    Description

    alarm_histories

    Array of objects

    No

    Specifies details about one or more alarm history records.

    For details, see Table 2.

    meta_data

    MetaData object

    No

    Specifies the total number of query results returned.

    For details, see Table 11.

    Table 2 alarm_histories data structure description

    Parameter

    Type

    Mandatory

    Description

    alarm_id

    String

    No

    Specifies the alarm rule ID, for example, al1603131199286dzxpqK3Ez.

    alarm_name

    String

    No

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

    alarm_description

    String

    No

    Provides supplementary information about the alarm rule.

    metric

    Metric object

    No

    Specifies the metric information.

    For details, see Table 3.

    condition

    Condition object

    No

    Specifies the alarm policy set in the alarm rule.

    For details, see Table 8.

    alarm_level

    Integer

    No

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

    alarm_type

    String

    No

    Specifies the alarm rule type. This parameter applies only to event alarms. The types are as follows:

    EVENT.SYS: system event alarm

    EVENT.CUSTOM: custom event alarm

    DNSHealthCheck: DNS health check alarm

    RESOURCE_GROUP: resource group alarm

    MULTI_INSTANCE: alarm for a specific resource

    alarm_enabled

    Boolean

    No

    Specifies whether the alarm rule has been enabled. Possible values are true and false.

    alarm_action_enabled

    Boolean

    No

    Specifies whether the alarm action has been triggered. Possible values are true and false.

    alarm_actions

    Array of objects

    No

    Specifies the action to be triggered by an alarm. The structure is as follows: {"type": "notification", "notificationList": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"] }

    The value of type can be one of the following:

    notification: indicates that a notification will be sent.

    autoscaling: indicates that a scaling action will be triggered.

    notificationList: indicates the list of objects to be notified if the alarm status changes.

    For details, see Table 5.

    ok_actions

    Array of objects

    No

    Specifies the action to be triggered after the alarm is cleared. The structure is as follows: {"type": "notification", "notificationList": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"] }

    The value of type can be one of the following:

    notification: indicates that a notification will be sent.

    notificationList: indicates the list of objects to be notified if the alarm status changes.

    For details, see Table 6.

    insufficientdata_actions

    Array of objects

    No

    Specifies the action triggered by data insufficiency. The structure is as follows: {"type": "notification", "notificationList": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"]}

    The value of type can be one of the following:

    notification: An alarm is triggered due to insufficient data.

    notificationList: Specifies the ID list of the notification objects when an alarm notification is triggered due to insufficient data.

    For details, see Table 7.

    update_time

    Long

    No

    Specifies when the alarm status changed. The time is a UNIX timestamp (ms), for example, 1603131199000.

    enterprise_project_id

    String

    No

    Specifies the enterprise project ID. Value all_granted_eps indicates all enterprise projects. Value 0 indicates enterprise project default.

    trigger_time

    Long

    No

    Specifies when the alarm was triggered. The time is a UNIX timestamp (ms), for example, 1603131199469.

    alarm_status

    String

    No

    Specifies the alarm status, which can be ok, alarm, or insufficient_data.

    datapoints

    Array of objects

    No

    Specifies when the monitoring data of the alarm history is reported and the monitoring data that is calculated.

    For details, see Table 9.

    additional_info

    AdditionalInfo object

    No

    Specifies the additional field of the alarm history, which applies only to the alarm history generated for event monitoring.

    For details, see Table 10.

    Table 3 metric data structure description

    Parameter

    Type

    Mandatory

    Description

    dimensions

    Array of objects

    Yes

    Specifies the metric dimension.

    For details, see Table 4.

    metric_name

    String

    Yes

    Specifies the metric name. Start with a letter. Enter 1 to 64 characters. Only letters, digits, and underscores (_) are allowed. For details, see the metric name queried in Services Interconnected with Cloud Eye.

    namespace

    String

    Yes

    Specifies the metric namespace in service.item format. service and item each must contain 3 to 32 characters, start with a letter, and contain only letters, digits, and underscores (_).

    NOTE:

    You can leave this parameter blank when you set alarm_type to (EVENT.SYS| EVENT.CUSTOM).

    Table 4 dimensions data structure description

    Parameter

    Type

    Mandatory

    Description

    name

    String

    No

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

    value

    String

    No

    Specifies the dimension value, for example, an ECS ID.

    Enter 1 to 256 characters.

    Table 5 alarm_actions data structure description

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    Specifies the alarm notification type.
    • notification: indicates that a notification will be sent.
    • autoscaling: indicates that a scaling action will be triggered.

    notificationList

    Array of strings

    Yes

    Specifies the list of objects to be notified if the alarm status changes.

    NOTE:

    The IDs in the list are strings. You can configure up to 5 object IDs.

    Table 6 ok_actions data structure description

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    Specifies the alarm notification type.
    • notification: indicates that a notification will be sent.
    • autoscaling: indicates that a scaling action will be triggered.

    notificationList

    Array of strings

    Yes

    Specifies the list of objects to be notified if the alarm status changes.

    NOTE:

    The IDs in the list are strings. You can configure up to 5 object IDs.

    Table 7 insufficientdata_actions data structure description

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    Specifies the alarm notification type.
    • notification: indicates that a notification will be sent.
    • autoscaling: indicates that a scaling action will be triggered.

    notificationList

    Array of strings

    Yes

    Specifies the list of objects to be notified if the alarm status changes.

    NOTE:

    The IDs in the list are strings. You can configure up to 5 object IDs.

    Table 8 condition data structure description

    Parameter

    Type

    Mandatory

    Description

    period

    Integer

    Yes

    Specifies how often Cloud Eye aggregates data, which can be

    • 1: Cloud Eye performs no aggregation and displays raw data.
    • 300: Cloud Eye aggregates data every 5 minutes.
    • 1200: Cloud Eye aggregates data every 20 minutes.
    • 3600: Cloud Eye aggregates data every hour.
    • 14400: Cloud Eye aggregates data every 4 hours.
    • 86400: Cloud Eye aggregates data every 24 hours.
    NOTE:

    If you set period to 1, Cloud Eye uses raw data to determine whether to trigger an alarm. You can set this parameter to 0 when you set alarm_type to (EVENT.SYS| EVENT.CUSTOM).

    filter

    String

    Yes

    Specifies the data rollup method, which can be

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

    comparison_operator

    String

    Yes

    Specifies the alarm threshold operator, which can be >, =, <, >=, or <=.

    value

    Double

    Yes

    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 ECS cpu_util in Services Interconnected with Cloud Eye to 80.

    unit

    String

    No

    Specifies the data unit. Enter up to 32 characters.

    count

    Integer

    Yes

    Specifies the number of consecutive occurrence times that the alarm policy was met. Supported range: 1 to 5

    suppress_duration

    Integer

    No

    Specifies the interval for triggering an alarm if the alarm persists. Possible intervals are as follows:

    0: Cloud Eye triggers the alarm only once.

    300: Cloud Eye triggers the alarm every 5 minutes.

    600: Cloud Eye triggers the alarm every 10 minutes.

    900: Cloud Eye triggers the alarm every 15 minutes.

    1800: Cloud Eye triggers the alarm every 30 minutes.

    3600: Cloud Eye triggers the alarm every hour.

    10800: Cloud Eye triggers the alarm every 3 hours.

    21600: Cloud Eye triggers the alarm every 6 hours.

    43200: Cloud Eye triggers the alarm every 12 hours.

    86400: Cloud Eye triggers the alarm every day.

    Table 9 datapoints data structure description

    Parameter

    Type

    Mandatory

    Description

    time

    Long

    No

    Specifies when the monitoring data of the alarm history is reported, which is a UNIX timestamp in milliseconds, for example, 1603131028000.

    value

    Double

    No

    Specifies the calculated monitoring data of the alarm history, for example, 7.019.

    Table 10 additional_info data structure description

    Parameter

    Type

    Mandatory

    Description

    resource_id

    String

    No

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

    resource_name

    String

    No

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

    event_id

    String

    No

    Specifies the event ID of the alarm history, for example, ev16031292300990kKN8p17J.

    Table 11 meta_data data structure description

    Parameter

    Type

    Mandatory

    Description

    total

    Integer

    Yes

    Specifies the total number of query results.

  • Example response
    {
     "alarm_histories": [
       {
         "alarm_id": "al1604473987569z6n6nkpm1",
         "alarm_name": "TC_CES_FunctionBaseline_Alarm_008",
         "alarm_description": "",
         "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
         },
         "alarm_level": 2,
         "alarm_type": "",
         "alarm_enabled": false,
         "alarm_action_enabled": false,
         "alarm_actions": [],
         "ok_actions": [],
         "insufficientdata_actions": [],
         "update_time": 1604473988000,
         "enterprise_project_id": "0",
         "trigger_time": 1604473987607,
         "alarm_status": "alarm",
         "datapoints": [
           {
             "time": 1604473860000,
             "value": 0
           },
           {
             "time": 1604473800000,
             "value": 0
           },
           {
             "time": 1604473740000,
             "value": 0
           }
         ],
         "additional_info": {
           "resource_id": "",
           "resource_name": "",
           "event_id": ""
         }
       },
       {
         "alarm_id": "al1604473978613MvlvlbVZD",
         "alarm_name": "alarm_merge",
         "alarm_description": "",
         "metric": {
           "namespace": "AGT.ECS",
           "dimensions": [
             {
               "name": "instance_id",
               "value": "22d98f6c-16d2-4c2d-b424-50e79d82838f"
             }
           ],
           "metric_name": "load_average5",
           "resource_group_id": "rg160447397837330303XQbK",
           "resource_group_name": "group1"
         },
         "condition": {
           "period": 1,
           "filter": "average",
           "comparison_operator": ">=",
           "value": 0,
           "count": 3
         },
         "alarm_level": 2,
         "alarm_type": "RESOURCE_GROUP",
         "alarm_enabled": false,
         "alarm_action_enabled": false,
         "alarm_actions": [],
         "ok_actions": [],
         "insufficientdata_actions": [],
         "update_time": 1604473979000,
         "enterprise_project_id": "0",
         "trigger_time": 1604473979070,
         "alarm_status": "insufficient_data",
         "datapoints": [],
         "additional_info": {
           "resource_id": "",
           "resource_name": "",
           "event_id": ""
         }
       }
     ],
     "meta_data": {
       "total": 2
     }
    }

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.