如何使用CloudWatch查看来自Cloudformation的EC2实例的详细监控?

时间:2018-04-05 10:48:45

标签: amazon-ec2 monitoring amazon-cloudformation amazon-cloudwatch

我可以从AWS控制台和命令行执行此操作:

aws ec2 monitor-instances --region --instance-ids

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-monitoring

我可以使用上面的Monitoring API,但是需要对现有的EC2实例进行此操作。

1 个答案:

答案 0 :(得分:0)

您只需使用 AWS :: CloudWatch :: Alarm 类型以及EC2实例支持的任何指标。

例如,假设您需要监视CPU利用率。

"CPUAlarm" : {
  "Type" : "AWS::CloudWatch::Alarm",
  "Properties" : {
    "AlarmDescription" : "CPU alarm for my instance",
    "AlarmActions" : [ { "Ref" : "logical name of an AWS::SNS::Topic resource" } ],
    "MetricName" : "CPUUtilization",
    "Namespace" : "AWS/EC2",
    "Statistic" : "Average",
    "Period" : "60",
    "EvaluationPeriods" : "3",
    "Threshold" : "90",
    "ComparisonOperator" : "GreaterThanThreshold",
    "Dimensions" : [ {
      "Name" : "InstanceId",
      "Value" : { "Ref" : "logical name of an AWS::EC2::Instance resource" }
    } ]
  }
}

参考 - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-cloudwatch.html