By using API callbacks, you can directly receive alarm notifications from the Cloud Platform (TCOP) on your self-built system. API callbacks can push alarm information to URLs that are accessible over the public network through HTTP POST requests. You can take further actions based on the alarm information pushed by API callbacks.
Usages
- Callback API: Users need to provide a URL that is capable of receiving HTTP POST requests and is accessible over the public network as the callback address.
- Callback trigger: the trigger logic is similar to that of alarm SMS and emails. When an alarm policy created by the user is triggered or the alarm is resolved, the alarm messages will be pushed through the API callbacks. API callbacks also support repeated alarms.
- Binding API Callbacks: Users can configure API callbacks during the API Callback step of creating an alarm, or add API callbacks on the alarm policy details page. A single alarm policy group can only be bound to one alarm callback URL.
- Returned content: After sending an alarm notification to the user's bound URL, we need to receive the following returned content to confirm that the user has successfully received the information; otherwise, we will resend the alarm notification, up to three times.
Note:
sessionId, used to authenticate the callback request.
retCode, to determine whether the request was successfully sent.
{ sessionId: "xxxxxxxx", retCode: 0 }Callback Parameters
The callback API will send data in JSON format through HTTP POST requests. The parameters are as follows:
{
"sessionId": "xxxxxxxx",
"alarmStatus": 1,
"alarmObjInfo": {
"region": "CAX01", // This field will not be returned for products that are not region-specific.
"namespace": "qce/cvm", // Product namespace
"dimensions": { // Content in the dimensions field varies by service.
"unInstanceId": "ins-o9p3rg3m",
"objId":"xxxxxxxxxxxx",
}
}
"alarmPolicyInfo": {
"policyId": "policy-n4exeh88", // ID of the alarm policy group.
"policyType": "cvm_device", // Alarm policy type.
"policyName": "test", // Name of the alarm policy group.
"conditions": {
"metricName": "cpu usage", // Metric name.
"metricShowName": "CPU usage", // Displayed metric name.
"calcType": ">>", // This field will not be returned for metrics without a threshold.
"calcValue": "90", // This field will not be returned for metrics without a threshold.
"currentValue": "100", // This field will not be returned for metrics without a threshold.
"unit": "%", // This field will not be returned for metrics without a threshold.
"period": "60", // This field will not be returned for metrics without a threshold.
"periodNum": "1", // This field will not be returned for metrics without a threshold.
"alarmNotifyType": "continuousAlarm", // Whether repeated alarms are supported, this field will not be returned for metrics without a threshold.
"alarmNotifyPeriod": 300 // Frequency of repeated alarms. This field will not be returned for metrics without a threshold.
}
"firstOccurTime": "2017-03-09 07:00:00", // TTime when the alarm is triggered for the first time.
"durationTime": 500, // Alarm duration in seconds.
"recoverTime": "0" // Time when the alarm is resolved in seconds. If it is not resolved, the value is 0.
}
}