What should a solutions architect recommend?
Configure an Amazon CloudWatch SwapUsage metric dimension. Monitor the SwapUsage dimension in the EC2 metrics in CloudWatch.
Use EC2 metadata to collect information, then publish it to Amazon CloudWatch custom metrics. Monitor SwapUsage metrics in CloudWatch.
Install an Amazon CloudWatch agent on the instances. Run an appropriate script on a set schedule. Monitor SwapUtilization metrics in CloudWatch.
Enable detailed monitoring in the EC2 console. Create an Amazon CloudWatch SwapUtilization custom metric. Monitor SwapUtilization metrics in CloudWatch.
Explanations:
The Amazon CloudWatch SwapUsage metric dimension does not exist. CloudWatch does not provide a default SwapUsage metric for monitoring EC2 instances, so this option would not provide the necessary monitoring capability for swap space.
While using EC2 metadata can provide some instance information, it does not inherently collect swap space usage. Publishing this data as custom metrics requires additional configuration, and there is no direct mechanism to monitor swap usage solely through EC2 metadata.
Installing the Amazon CloudWatch agent allows for the collection of more granular metrics, including swap utilization. By running a script on a schedule, the agent can publish relevant metrics such as SwapUtilization to CloudWatch, enabling effective monitoring of swap space.
Detailed monitoring in the EC2 console does not provide a specific SwapUtilization metric by default. Creating a custom metric for SwapUtilization would still require additional steps beyond enabling detailed monitoring, making this option less viable for direct monitoring of swap space.