A company observes that a newly created Amazon CloudWatch alarm is not transitioning out of the INSUFFICIENT_DATA state. The alarm was created to track the mem_used_percent metric from an Amazon EC2 instance that is deployed in a public subnet.
A review of the EC2 instance shows that the unified CloudWatch agent is installed and is running. However, the metric is not available in CloudWatch. A SysOps administrator needs to implement a solution to resolve this problem
Which solution will meet these requirements?
Objective:
Ensure the mem_used_percent metric from the EC2 instance is available in Amazon CloudWatch.
Root Cause:
The unified CloudWatch agent requires IAM permissions to publish custom metrics to CloudWatch.
If an IAM instance profile is not attached or is missing necessary permissions, the metric will not appear in CloudWatch.
Solution Implementation:
Step 1: Create an IAM role with the required permissions:
Use the AmazonCloudWatchAgentServerPolicy managed policy, which grants permissions for the CloudWatch agent to send metrics.
Step 2: Create an IAM instance profile for the role.
Step 3: Attach the instance profile to the EC2 instance.
Step 4: Restart the unified CloudWatch agent on the EC2 instance to apply the changes:
bash
Copy code
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a start
AWS Reference:
Unified CloudWatch Agent Configuration: CloudWatch Agent Permissions
Why Other Options Are Incorrect:
Option A: Enabling detailed monitoring only collects predefined metrics; it does not affect custom metrics like mem_used_percent.
Option C: The subnet (public or private) does not affect the collection of metrics by the CloudWatch agent.
Option D: Using IAM user credentials is not a best practice for EC2 instances; instance profiles are the recommended method.
Vince
3 days agoStephanie
4 days agoGregoria
5 days ago