百度智能云

All Product Document

          Cloud Monitor

          Alarm Callback

          Through the alarm callback, the alarm notification of the BCM cloud monitoring can be sent to your designated URL. You can handle all kinds of alarm information freely and flexibly. BCM supports to push the POST request through HTTP/HTTPS protocol to the URL of accessible public network. You can handle the alarm information further pushed based on the callback interface.

          Currently, BCM provides alarm callback feature for the monitoring of the cloud products (including threshold alarm and event alarm), and the alarm callback feature like site monitoring, application monitoring and customized monitoring will be enabled later.

          Instructions for Alarm Callback

          • Alarm callback interface: You need to provide the POST request that can receive HTTP/HTTPS protocol, and URL address to which the public network can access as the callback address.
          • Triggering of alarm callback: If you enter the alarm callback address, the trigger logic is consistent with the alarm information, mail and phone; when the created alarm policy is triggered, or the alarm policy is resumed, the alarm message will be sent through the alarm callback interface.
          • Bind the alarm callback interface: You can add the callback interface when creating the alarm policy. One alarm policy can be bound with one alarm callback URL.
          • Returned contents: When an alarm information is sent to the bound URL, we need to receive the returned content (httpCode = 200) that the identification is successful to indicate that the alarm information is received successfully; otherwise, we will send the alarm information repeatedly, with a maximum of three times, and a timeout of 5s (retry mechanism)

          Operation Steps

          Currently, the cloud product monitoring provides the alarm callback feature, with two entries:

          • Entry 1: Unified entry to create the alarm strategy

            1.Click the - in the navbar on the left, and click "Add Policy" under the policy list of the cloud product monitoring.

          2.On the page of creating policies, enable the alarm callback feature, select the protocol mode and enter the URL address to which the public network can access.

          Note: The callback token is used to verify whether the alarm message you received is sent by BCM monitored by Baidu AI Cloud. BCM will generate a token automatically, click button to change the callback token; meanwhile, you need to change the verification Token in the callback program, and the latest token is used during the callback.

          • Entry 2: The entry to create the alarm strategy for a single instance under a cloud service

            1.In the left navigation bar, click . Click the cloud product name to be viewed, and enter the page of instance list of the cloud product. To view the monitoring data of the cloud server BCC, click to enter the page of "cloud server list". Select corresponding instance and click the "Add Policy".

          2.On the page of creating policies, enable the alarm callback and enter the necessary information.

          Instruction for POST Mode Parameter

          Instruction for metric alarm POST mode parameter

          Parameter Instruction
          alertId Alarm ID
          userId Account ID
          alarmName Name of alarm strategy
          scope Name of cloud product
          policyType Policy type (one of the metric alarm and event alarm, among which Metric represents the metric alarm and Event represents the event alarm)
          alertStartTimestamp Timestamp when the alarm occurs
          region The region where the alarm object is located
          monitoringObject Object of alarm
          alarmLevel Status of alarm level. Return one of the four statuses, including severity, notification, importance and alarm according to the actual situation
          formula Alarm condition
          currentValue Current value of the monitoring item when an alarm occurs or resumed
          taskTimestamp Alarm callback sending time
          signature Signature

          Instruction for event alarm POST mode parameter

          Parameter Instruction
          alarmName Name of alarm strategy
          scope Name of cloud product
          alertStartTimestamp Timestamp when the alarm occurs
          alertContent Event details
          taskTimestamp Alarm callback sending time
          signature Signature

          The signature value is validated by linking the three parameters -- alertId, token and taskTimestamp generated during the configuration, and equal to the encrypted value of MD5 algorithm.

          Instance for URL callback

          The following is a use instance of URL callback, a URL callback request in the mode of POST initiated by BCM:

          POST http://127.0.0.1:8201/callback
          POST: alertId=dffvsdfsdffa&userId=a0345uiiiooo&alarmName=test&scope=BCE_BCC&policyType=Metric&alertStartTimestamp=1597489020&region=North China-Baoding &monitoringObject=BCC instance i-gid9sff&alarmLevel=MAJOR&formula=cpu usage rate >70% 
           &currentValue=cpu usage rate =87%&taskTimestamp=1597489090&signature=af7c6cvbnjkdfghjk 

          Receive POST parameter in the callback.java file and validate the message:

          // Resolve these 3 parameters, namely alertId, taskTimestamp and signature from the POST request sent from Use the three parameters, namely alertId, token (token generated when creating the alarm strategy) and taskTimestamp to connect and validate the message with the value encrypted by MD5 algorithm. 
           If the verification succeeds, it indicates that the message is sent by Baidu AI Cloud; otherwise, it is an invalid request, and shall not be processed. Among them, taskTimestamp can be used for expired verification, if the timestamp and the time interval of the user's current time are greater than a cycle (such as 10 minutes), the user can discard the request on its own. 
          
          if (md5(alertId + token + taskTimestamp) == signature) {
              ..........
          }
          Previous
          Management Alarm
          Next
          Alarm Action