Querying Alarm History

Function

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

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. Possible values are ok, alarm, or insufficient_data.

    alarm_level

    No

    Specifies the alarm severity. Possible values are 1 (critical), 2 (major), 3 (minor), and 4 (informational).

    namespace

    No

    Specifies the resource namespace. For example, the ECS resource 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 set from or to, the value of to is the current time by default, and the value of from is the timestamp of seven days earlier than the current time.

    to

    No

    Specifies the time when you want your alarm history query to end. The time is a UNIX timestamp (ms). The value of from must be less than or equal to that of to. If you do not set from or to, the value of to is the current time by default, and the value of 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. The value range is (0,100] and the default value is 100.

  • Example
    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/alarms/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.

    meta_data

    MetaData object

    No

    Specifies the total number of query results returned.

    Table 2 alarm_histories field 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.

    condition

    Condition object

    No

    Specifies the alarm policy set in the alarm rule.

    alarm_level

    Integer

    No

    Specifies the alarm severity. Possible values are 1 (critical), 2 (major), 3 (minor), and 4 (informational).

    alarm_type

    String

    No

    Specifies the alarm type. This parameter is valid only for event monitoring. Possible values are EVENT.SYS and EVENT.CUSTOM.

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

    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 to the user.

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

    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.

    update_time

    Long

    No

    Specifies the time 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 the time when the alarm was triggered. The time is a UNIX timestamp (ms), for example, 1603131199469.

    alarm_status

    String

    No

    Specifies the alarm status. Possible values are ok, alarm, or insufficient_data.

    datapoints

    Array of objects

    No

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

    additional_info

    AdditionalInfo object

    No

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

    Table 3 metric data structure description

    Parameter

    Type

    Mandatory

    Description

    dimensions

    Arrays of objects

    Yes

    Specifies the metric dimension.

    metric_name

    String

    Yes

    Specifies the metric name. The value can be a string of 1 to 64 characters, must start with a letter, and contain only letters, digits, and underscores (_). 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 be a string of 3 to 32 characters, must start with a letter, and contain only letters, digits, and underscores (_).

    NOTE:

    This parameter can be left blank when alarm_type is set to (EVENT.SYS| EVENT.CUSTOM).

    Table 4 dimensions field 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.

    The value is a string of 1 to 256 characters.

    Table 5 alarm_actions field data structure description

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    Specifies the alarm notification type.
    • notification: indicates that a notification will be sent to the user.
    • 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 character strings. You can configure up to 5 object IDs.

    Table 6 ok_actions field data structure description

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    Specifies the alarm notification type.
    • notification: indicates that a notification will be sent to the user.
    • 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 character strings. You can configure up to 5 object IDs.

    Table 7 insufficientdata_actions field data structure description

    Parameter

    Type

    Mandatory

    Description

    type

    String

    Yes

    Specifies the alarm notification type.
    • notification: indicates that a notification will be sent to the user.
    • 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 character strings. You can configure up to 5 object IDs.

    Table 8 condition field data structure description

    Parameter

    Type

    Mandatory

    Description

    period

    Integer

    Yes

    Specifies how often Cloud Eye aggregates data.

    Possible values:

    • 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 1 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. The following methods are supported:

    • 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 operator of alarm thresholds. Possible values are >, =, <, , and .

    value

    Double

    Yes

    Specifies the alarm threshold. The value ranges from 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. The value contains a maximum of 32 characters.

    count

    Integer

    Yes

    Specifies the number of consecutive occurrence times that the alarm policy was met. The value ranges from 1 to 5.

    suppress_duration

    Integer

    No

    Specifies the interval for triggering an alarm if the alarm persists.

    Possible values 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 1 hour.

    10800: Cloud Eye triggers the alarm every 3 hours.

    21600: Cloud Eye triggers the alarm every 6 hour.

    43200: Cloud Eye triggers the alarm every 12 hours.

    86400: Cloud Eye triggers the alarm every day.

    Table 9 datapoints field data structure description

    Parameter

    Type

    Mandatory

    Description

    time

    Long

    No

    Specifies the time when the monitoring data of the alarm history is reported. The value 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 field 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 field 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 Value

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    The authentication information is not provided or is incorrect.

    403 Forbidden

    You are forbidden to access the page requested.

    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 Code

For details, see Error Codes.