SOA-C02 Question 14
Select 3You have an EC2 instance running Amazon Linux 2, and you want to collect both custom application logs and system-level metrics, such as disk usage and memory utilization, to Amazon CloudWatch. Which of the following steps must you take to properly configure and collect this data using the CloudWatch agent?
- A
Install the CloudWatch agent on the EC2 instance and configure the agent using the
amazon-cloudwatch-agent-config-wizardtool. - B
Manually create a CloudWatch log group and log stream for the application logs before starting the CloudWatch agent.
- C
Attach the appropriate IAM role with permissions to write metrics and logs to CloudWatch to the EC2 instance.
- D
Configure the
cloudwatch-config.jsonfile to specify the metrics and logs to be collected and restart the CloudWatch agent service. - E
Enable detailed monitoring for the EC2 instance to allow CloudWatch to automatically collect custom logs and metrics.
Show answer and explanation
Correct answers: A, C, D
Explanation
To collect custom application logs and system metrics using the CloudWatch agent, you need to install and configure the agent on the EC2 instance. The configuration can be done interactively with the amazon-cloudwatch-agent-config-wizard or by editing the cloudwatch-config.json file. Additionally, the EC2 instance must have an IAM role with permissions to write to CloudWatch. Manually creating log groups and enabling detailed monitoring are not required for this specific scenario.
- A. Correct.
Correct: Installing the CloudWatch agent and using the
amazon-cloudwatch-agent-config-wizardis a primary step to configure and start collecting metrics and logs. - B. Incorrect.
Incorrect: While manually creating a log group and stream is possible, the CloudWatch agent automatically creates them if they are not already present.
- C. Correct.
Correct: The EC2 instance requires an IAM role with appropriate permissions (e.g.,
CloudWatchAgentServerPolicy) to send metrics and logs to CloudWatch. - D. Correct.
Correct: Configuring the
cloudwatch-config.jsonfile is necessary to define what metrics and logs the CloudWatch agent should collect. Restarting the agent applies the configuration changes. - E. Incorrect.
Incorrect: Enabling detailed monitoring collects additional default metrics for the EC2 instance but does not enable collection of custom logs or application-specific metrics.