如何通过CloudFormation使用CloudWatch查看EC2实例的详细监控?
Enable Detailed CloudWatch Monitoring for EC2 via CloudFormation
If you want to set up detailed CloudWatch monitoring for EC2 instances during creation (instead of relying on the post-launch aws ec2 monitor-instances command), you can directly configure this in your CloudFormation template using the EC2 Instance resource's Monitoring property.
Key Configuration Step
In your CloudFormation template, add the Monitoring attribute to your AWS::EC2::Instance resource and set its value to true. This switches the instance from default basic monitoring (5-minute metric intervals) to detailed monitoring (1-minute intervals).
Example CloudFormation Snippet
Resources: MyMonitoredEC2Instance: Type: AWS::EC2::Instance Properties: ImageId: ami-1234567890abcdef0 # Replace with your target AMI ID InstanceType: t2.micro Monitoring: true # Enables detailed CloudWatch monitoring # Include other required properties like SubnetId, SecurityGroupIds, etc.
Important Notes
- Cost Reminder: Detailed CloudWatch monitoring comes with additional charges compared to basic monitoring. Be sure to account for this if enabling it across multiple instances.
- No Post-Deployment Steps: Unlike the
monitor-instancesCLI/console action that targets existing instances, this setting takes effect as soon as the EC2 instance is provisioned via CloudFormation—no extra work needed after deployment. - Enhanced Metrics Access: With detailed monitoring enabled, you’ll get access to the full suite of EC2 metrics (CPU utilization, disk I/O, network throughput, etc.) at 1-minute granularity in the CloudWatch console.
内容的提问来源于stack exchange,提问作者Jack
相关产品推荐
相关产品推荐

