我可以从AWS控制台和命令行执行此操作:
aws ec2 monitor-instances --region --instance-ids
我可以使用上面的Monitoring API,但是需要对现有的EC2实例进行此操作。
答案 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