amazon-web-services - 如何将多个单独的维度用于自定义 cloudwatch 指标?

标签 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 命名空间中),以便我可以使用我的警报。
我怎样才能做到这一点?

最佳答案

尝试设置 aggregation_dimensions

像这样:

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

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

关于amazon-web-services - 如何将多个单独的维度用于自定义 cloudwatch 指标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56467879/

相关文章:

deployment - 使用 Ansible 自动配置 AWS 自动缩放组实例

amazon-web-services - 启动 ec2 服务器时自动启动 docker

amazon-web-services - AWS CloudWatch Logs Archive(不是 S3),如何使用它

amazon-web-services - 解析 AWS cloudwatch 洞察中的消息后分组依据

amazon-web-services - AWS 网络负载均衡器问题

Kubernetes,一个VPA可以管理多个Cronjobs吗?

amazon-web-services - 遇到不受支持的属性 SourceSecurityGroupId

amazon-web-services - Terraform 不会将步骤函数部署到 API 网关

amazon-web-services - EC2 Container Registry入门

amazon-web-services - 重构 Terraform 以使用索引时防止资源破坏