このページは機械翻訳によるものです。内容の正確さは保証しておりません。 人力翻訳を依頼する

Simple Message Queue (旧MNS) へのアラート情報の書き込み

更新日時2024-10-23 08:07

このトピックでは、アラート情報をSimple Message Queue (旧MNS) (SMQ) に書き込む方法について説明します。

手順

  1. CloudMonitorにアラート情報をSMQに書き込む権限を付与します。

    1. Go to theクラウドリソースへのアクセス許可ページを開き、CloudMonitorがAliyunCloudMonitorDefaultRoleロールを引き受けることを許可します。

    2. クリック承認ポリシーの確認.

  2. PutResourceMetricRule操作を呼び出して、アラートルールを作成します。

    詳細については、「PutResourceMetricRule」をご参照ください。

  3. PutMetricRuleTargets操作を呼び出して、指定されたアラートルールのアラートメッセージを作成し、指定されたSMQキューに書き込みます。

    詳細については、「PutMetricRuleTargets」をご参照ください。

    SMQキューのAlibaba Cloudリソース名 (ARN) は、"acs:mns :{$ RegionId }:{$ UserId}:/queues/{$queueName}/messages" 形式です。

    次のコードは、PutMetricRuleTargets操作の例を示しています。

    RuleId:"putNewAlarm_group_778af9ba-a291-46ab-ac53-3983bcee****",
    Targets:[{
        Id: 1,
        Arn:"acs:mns:{$RegionId}:{$UserId}:/queues/{$queueName}/messages",
        Level: ["INFO", "WARN", "CRITICAL"],
    }]

SMQに書き込まれるメッセージ本文

CloudMonitorは、メッセージ本文をJSON形式でSMQに書き込みます。 次のコードは、JSON形式のメッセージ本文の例を示しています。

{
  "ruleId": "putNewAlarm_group_778af9ba-a291-46ab-ac53-3983bcee****",
  "ruleName": "test123",
  // The current alert level. 
  "curLevel": "WARN",
  // The previous alert 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,
    // The historical value of the AliyunCmsPrevValues parameter. For example, you can compare the value in the current period between today and yesterday. 
    "AliyunCmsPrevValues": { 
      "timestamp": 1534649760000,
      "userId": "127067667954****",
      "instanceId": "i-uf61rfofjd2iku7e****",
      "Average": 468463616,
      "Maximum": 468549632,
      "Minimum": 468258816
    },
    // The comparison formula. 
    "AliyunCmsComplexExpression": "100.0 * ($Average-$$prevAverage)/$$prevAverage",
    // The conversion formula. 
    "AliyunCmsComplexMath": "100.0 * (470687744-468463616)/468463616",
    // The calculation result. 
    "AliyunCmsComplexValue": 0.47477070236336133
  },
  // The metric information. 
  "metricName": "memory_actualusedspace#60",
  "namespace": "acs_ecs_dashboard",
  "period": "60",

  // The information about the application group. 
  "groupBy": "group",
  "productGroupName": "ECS instance",
  "groupId":"7301****",

  // The alert time. 
  "lastTime": 327362743, // The duration of the alert. Unit: milliseconds. 
  "time": 1534736160000, // The time when the alert was generated. Unit: milliseconds. 

  "userId": "173651113438****",
  "eventName": "AlertOk",
  "eventType": "Alert",
  // The trace information. 
  "batchId": "4272653-152082****",
  "version": "1.0"
}
  • 目次 (1, M)
  • 手順
  • SMQに書き込まれるメッセージ本文
フィードバック
phone お問い合わせ

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare