如何对自定义的CloudWatch指标使用多个单独的维度?

时间:2019-06-05 20:55:50

标签: amazon-web-services amazon-cloudwatch autoscaling amazon-cloudwatch-metrics

通过此操作,我们可以为自定义指标配置维度。

{
   "metrics":{
      "append_dimensions":{
         "AutoScalingGroupName":"${!aws:AutoScalingGroupName}",
         "ImageId":"${!aws:ImageId}",
         "InstanceId":"${!aws:InstanceId}",
         "InstanceType":"${!aws:InstanceType}"
      },
      "metrics_collected":{
         "mem":{
            "measurement":[
               "mem_used_percent"
            ]
         },
         "swap":{
            "measurement":[
               "swap_used_percent"
            ]
         }
      }
   }
}

这给出了类似的内容: enter image description here

现在,我尝试为尺寸自动缩放组创建警报:

  MemoryAlarmHigh:
   Type: AWS::CloudWatch::Alarm
   Properties:
     EvaluationPeriods: '1'
     Statistic: Average
     Threshold: '70'
     AlarmDescription: Go in Alarm is memory is higher than 70% for 60 seconds
     Period: '60'
     AlarmActions:
     - Ref: ScaleUpPolicy
     Namespace: CWAgent
     Dimensions:
     - Name: AutoScalingGroupName
       Value: !Ref ASG
     ComparisonOperator: GreaterThanThreshold
     MetricName: xxx

这不起作用。我没有足够的数据。 现在,当我使用

            {
              "metrics": {
                "append_dimensions": {
                  "AutoScalingGroupName": "${!aws:AutoScalingGroupName}"
                },
                "metrics_collected": {
                  "mem": {
                    "measurement": [
                      "mem_used_percent"
                    ]
                  }
                }
              }
            }

我得到: enter image description here

并且警报现在起作用。但是我想使用多个维度,但要分别使用它们(例如在EC2名称空间中),以便使用警报。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

尝试设置cd /env/Lib/site-packages/ ls Directory: C:<path/to/site-packages> Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- <today's date> numpy d----- <today's date> numpy-1.16.4.dist-info

赞:

aggregation_dimensions

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html#CloudWatch-Agent-Configuration-File-Metricssection