Querying Alarm History
Function
This API is used to query the alarm history.
URI
GET /V1.0/{project_id}/alarm-histories
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
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, see Obtaining a Project ID. Constraints N/A Range 1 to 64 characters Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
group_id |
No |
String |
Definition: Information about the group that the current resource belongs to. Constraints: N/A Range: The value starts with rg and is followed by 22 characters of letters, digits, or a combination of both. Default Value: N/A |
|
alarm_id |
No |
String |
Definition: Alarm rule ID. Constraints: N/A Range: The value starts with al and is followed by 22 characters of letters, digits, or a combination of both. Default Value: N/A |
|
alarm_name |
No |
String |
Definition: Alarm rule name. Constraints: N/A Range: The value allows 1 to 128 characters and can only contain digits, letters, underscores (_), and hyphens (-). Default Value: N/A |
|
alarm_status |
No |
String |
Definition: Alarm status. The options are ok, alarm, insufficient_data, and invalid. Constraints: N/A Range: The value can be ok, alarm, insufficient_data, or invalid. Default Value: N/A |
|
alarm_level |
No |
Integer |
Definition: Severity of the alarm record. The value can be 1, 2, 3, or 4. Constraints: N/A Range: The value can be 1 (critical), ** 2** (major), 3 (minor), or 4 (informational). Default Value: N/A |
|
namespace |
No |
String |
Definition: Namespace of a service. For details about the namespace of each service, see Namespaces. Constraints: N/A Range: The value is in the service.item format. The values of service and item must be a string, starting with a letter and containing only digits (0–9), letters (case-insensitive), and underscores (_). It must contain 3 to 32 characters. Default Value: N/A |
|
from |
No |
String |
Definition: Start time of a time range used for filtering traces by time (excluding the time the traces were imported). The value is a timestamp. Constraints: N/A Range: [1,13] Default Value: N/A |
|
to |
No |
String |
Definition: End time of a time range used for filtering traces by time (excluding the time the traces were imported). The value is a timestamp. Constraints: N/A Range: [1,13] Default Value: N/A |
|
start |
No |
String |
Definition: Start position for pagination query, indicating the sequence number of the data record where the query starts. Constraints: N/A Range: ^(0|[1-9][0-9]*)$ Default Value: 0 |
|
limit |
No |
Integer |
Definition: Maximum number of records being queried. Constraints: N/A Range: [1,100] Default Value: 100 |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
Content-Type |
No |
String |
Definition MIME type of the request body. Constraints N/A Range 1 to 64 characters Default Value The default value is application/json; charset=UTF-8. For APIs used to upload objects or images, the MIME type varies with the flow type. |
|
X-Auth-Token |
No |
String |
Definition User token. Constraints N/A Range 1 to 16,384 characters Default Value N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
alarm_histories |
Array of AlarmHistoryInfo objects |
Details about one or more alarm history records. |
|
meta_data |
MetaDataForAlarmHistory object |
Total number of returned alarm history records. |
|
Parameter |
Type |
Description |
|---|---|---|
|
alarm_id |
String |
Alarm rule ID, for example, al1603131199286dzxpqK3Ez. |
|
alarm_name |
String |
Alarm rule name, for example, alarm-test01. |
|
alarm_description |
String |
Alarm rule description. |
|
metric |
MetricInfo object |
Metric information. |
|
condition |
Condition object |
Definition: Alarm policy configured in the alarm rule. Constraints: N/A |
|
alarm_level |
Integer |
Severity of the alarm record. The value can be 1 (critical), 2 (major), 3 (minor), or 4 (informational). |
|
alarm_type |
String |
Alarm type. This parameter is valid only for event alarms. The value can be EVENT.SYS or EVENT.CUSTOM. |
|
alarm_enabled |
Boolean |
Whether the alarm rule has been enabled. The value can be true or false. |
|
alarm_action_enabled |
Boolean |
Whether the alarm action has been triggered. The value can be true or false. |
|
alarm_actions |
Array of AlarmActions objects |
Action to be triggered by an alarm. A structure example is as follows: { "type": "notification", "notificationList": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"] } The type value can be notification (a notification action will be triggered) or autoscaling (a scaling action will be triggered). notificationList indicates the recipients to be notified of the alarm status changes. |
|
ok_actions |
Array of AlarmActions objects |
Action to be triggered after an alarm is cleared. A structure example is as follows: { "type": "notification", "notificationList": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"] } The value of type can be notification (a notification action will be triggered). notificationList indicates list of recipients to be notified of alarm status changes. |
|
insufficientdata_actions |
Array of AlarmActions objects |
Action triggered due to insufficient data. A structure example is as follows: { "type": "notification", "notificationList": ["urn:smn:southchina:68438a86d98e427e907e0097b7e35d47:sd"] } typeindicates that the alarm notification is triggered due to insufficient data and its value is notification. notificationList indicates IDs of the recipients for receiving alarm notifications triggered due to insufficient data. |
|
update_time |
Long |
Time when the alarm status changed. The value is a UNIX timestamp in milliseconds, for example, 1603131199000. |
|
enterprise_project_id |
String |
Enterprise project ID. The value can be all_granted_eps (all enterprise projects) or 0 (default enterprise project). |
|
trigger_time |
Long |
Time when the monitoring data of the alarm history was reported. The value is a UNIX timestamp in milliseconds, for example, 1603131199469. |
|
alarm_status |
String |
Alarm status, which can be ok, alarm, or insufficient_data. |
|
datapoints |
Array of DataPointForAlarmHistory objects |
An array of data about the time when the monitoring data of the alarm history is reported and the monitoring metric values that are calculated. |
|
additional_info |
AdditionalInfo object |
Additional field of the alarm history, which applies only to the alarm history generated for event monitoring. |
|
notification_manner |
String |
Notification method. NOTIFICATION_POLICY indicates notification policies, NOTIFICATION_GROUP indicates notification groups, and TOPIC_SUBSCRIPTION indicates topic subscriptions. |
|
Parameter |
Type |
Description |
|---|---|---|
|
namespace |
String |
Metric namespace, which must be in the service.item format and contain 3 to 32 characters. service and item each must start with a letter and contain only letters, digits, and underscores (_). Note: This parameter can be empty when alarm_type is set to EVENT.SYS or EVENT.CUSTOM. For example, the ECS namespace is SYS.ECS, and the DDS namespace is SYS.DDS. For the namespace of each service, see Service Namespaces. |
|
metric_name |
String |
Definition: Metric ID. For example, metric_name of ECS CPU usage is cpu_util. For details about the namespace of each service, see [Service Namespace] (ces_03_0059.xml). Constraints: None Range: The value must start with a letter and can contain only digits, letters (case-insensitive), underscores (_), and hyphens (-). 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. The length of the character string is [1,96]. Default Value: None |
|
dimensions |
Array of MetricsDimension objects |
Definition: Dimension of a metric. Constraints: A maximum of four dimensions are supported. |
|
Parameter |
Type |
Description |
|---|---|---|
|
name |
String |
Definition: Dimension of a resource. For example, the dimension of an ECS can be instance_id. A maximum of four dimensions are supported. For the metric dimension of each resource, see Service metric dimension. Constraints N/A Range: The value starts with a letter and can contain letters, digits, underscores (_), or hyphens (-). The length is [1,32] characters. Default Value: N/A |
|
value |
String |
Definition Resource dimension value, which is an instance ID, for example, 4270ff17-aba3-4138-89fa-820594c39755. Constraints N/A Range 1 to 256 characters Default Value N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
comparison_operator |
String |
Definition: Operator of an alarm threshold. Constraints: N/A Range:
NOTE:
, =, <, >=, <=, or !=
Default Value: N/A |
|
count |
Integer |
Definition: Number of consecutive times that an alarm is triggered. Constraints: N/A Range: The value ranges from 1 to 5. For event alarms, the value ranges from 1 to 100. Default Value: N/A |
|
filter |
String |
Definition: Data aggregation method. Constraints: N/A Range: The value can be:
Default Value: N/A |
|
period |
Integer |
Definition Metric period, in seconds. For details about the original metric period for each cloud service, see Supported Services. Constraints N/A Range The value can be:
Default Value N/A |
|
unit |
String |
Definition: Data unit. Constraints: N/A Range: [0,32] Default Value: N/A |
|
value |
Number |
Definition: Specifies the alarm threshold. For details about the threshold value, see the value range of each service monitoring metric in the appendix. For example, the value range of cpu_util for ECS in [Services That Can Be Monitored] (ces_03_0059.xml) can be set to 80. Constraints: If there is only one threshold, value and alarm_level are used in pairs. If there are both hierarchical_value and value, hierarchical_value is used. Range: The minimum value is -1.7976931348623157e+108, and the maximum value is 1.7976931348623157e+108. Default Value: None |
|
Parameter |
Type |
Description |
|---|---|---|
|
[items] |
Array of Notification objects |
Definition: Information about the notification group or topic subscription when an alarm is triggered. Constraints: A maximum of 20 actions are supported. |
|
Parameter |
Type |
Description |
|---|---|---|
|
type |
String |
Definition: Alarm notification type. Constraints: N/A Range: notification (SMN notifications) or autoscaling (AS notifications) Default Value: N/A |
|
notificationList |
Array of strings |
Definition: Recipients to be notified of the alarm status changes. Constraints: A maximum of 20 recipients can be configured. 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 left blank. If type is set to autoscaling, the value of notificationList must be left blank. Note: If alarm_action_enabled is set to true, you must specify either alarm_actions or ok_actions. (You do not need to configure the deprecated parameter insufficientdata_actions.) If alarm_actions and ok_actions coexist, their notificationList values must be the same. (You do not need to configure the deprecated parameter insufficientdata_actions.) |
|
Parameter |
Type |
Description |
|---|---|---|
|
time |
Long |
Time when the monitoring data of the alarm history is reported, which is a UNIX timestamp in milliseconds, for example, 1603131028000. |
|
value |
Double |
Resource monitoring data of the alarm history at the time point, for example, 7.019. |
|
Parameter |
Type |
Description |
|---|---|---|
|
resource_id |
String |
Resource ID corresponding to the alarm history, for example, 22d98f6c-16d2-4c2d-b424-50e79d82838f. |
|
resource_name |
String |
Resource name corresponding to the alarm history, for example, ECS-Test01. |
|
event_id |
String |
ID of the event in the alarm record, for example, ev16031292300990kKN8p17J. |
|
Parameter |
Type |
Description |
|---|---|---|
|
total |
Integer |
Total number of returned alarm history records. |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Request error. |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
The authentication information is not provided or is incorrect. |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Access to the requested page is forbidden. |
Status code: 408
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
The request timed out. |
Status code: 429
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Too many requests. |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Failed to complete the request because of an internal service error. |
Status code: 503
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
The system is currently unavailable. |
Example Requests
/V1.0/{project_id}/alarm-histories?limit=10&start=0&from=1602494921346&to=1603099721346&alarm_name=alarm-test01
Example Responses
Status code: 200
OK
{
"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"
},
"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
}
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
OK |
|
400 |
Bad Request |
|
401 |
Unauthorized |
|
403 |
Forbidden |
|
408 |
Request Timeout |
|
429 |
Too Many Requests |
|
500 |
Internal Server Error |
|
503 |
Service Unavailable |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.