This topic describes how to write alerts from Cloud Monitor to Message Service (MNS).
Procedure
Message body written to MNS
Cloud Monitor writes a message body to MNS in the JSON format. The following code shows an example of a message body in the JSON format:
{
"ruleId": "putNewAlarm_group_778af9ba-a291-46ab-ac53-3983bcee****",
"ruleName": "test",
// Current level.
"curLevel": "WARN",
// Previous level.
"preLevel": "OK",
// The instance that triggers the alert.
"resources": "{\"instanceId\": \"i-uf61rfofjd2iku7e****\"}",
// The condition that triggers the alert.
"escalation": {
"comparisonOperator": "GreaterThanYesterday",
"level": 3,
"statistics": "Average",
"tag": "WARN",
"threshold": "0",
"times": 1
},
"metricData": {
"timestamp": 1534736160000,
"userId": "127067667954****",
"instanceId": "i-uf61rfofjd2iku7e****",
"Average": 470687744,
"Maximum": 470794240,
"Minimum": 470556672,
// Start the comparison of metrics.
"AliyunCmsPrevValues": { // Compared values.
"timestamp": 1534649760000,
"userId": "127067667954****",
"instanceId": "i-uf61rfofjd2iku7e****",
"Average": 468463616,
"Maximum": 468549632,
"Minimum": 468258816
},
// Comparison formula.
"AliyunCmsComplexExpression": "100.0 * ($Average-$$prevAverage)/$$prevAverage",
// Conversion formula.
"AliyunCmsComplexMath": "100.0 * (470687744-468463616)/468463616",
// Calculation result.
"AliyunCmsComplexValue": 0.47477070236336133
// End the comparison of metrics.
},
// Metric parameters.
"metricName": "memory_actualusedspace#60",
"namespace": "acs_ecs_dashboard",
"period": "60",
// Application group parameters.
"groupBy": "group",
"productGroupName": "RDS instance group",
"groupId":"12345",
// Alert time.
"lastTime": 327362743, // The duration of the alert.
"time": 1534736160000, // The time when the alert occurred.
"userId": "173651113438****",
"eventName": "AlertOk",
"eventType": "Alert",
// Use the following parameters to trace the alert.
"batchId": "4272653-152082****-0",
"version": "1.0"
}