What is the MOST operationally efficient way to accomplish this goal?
Create an AWS Lambda function to capture memory utilization of the EC2 instances. Schedule the Lambda function with Amazon EventBridge (Amazon CloudWatch Events).
Deploy the application to memory optimized EC2 instances. Use the CloudWatch MemoryUtilization metric.
Install the CloudWatch agent on the EC2 instances to collect and send metrics to CloudWatch.
Install the CloudWatch monitoring scripts on the EC2 instances to collect and send metrics to CloudWatch.
Explanations:
Using AWS Lambda to capture memory utilization adds unnecessary complexity and overhead. Lambda would need to access the EC2 instances, which is not efficient for monitoring memory on a large fleet.
The CloudWatch MemoryUtilization metric is only available for specific EC2 instance types (e.g., EC2 instances with Amazon Linux 2, or other supported instance types), and may not be available or comprehensive for all cases.
Installing the CloudWatch agent on the EC2 instances is the most operationally efficient solution. The agent collects detailed memory metrics and sends them to CloudWatch, supporting a scalable and automated approach.
The CloudWatch monitoring scripts are outdated and no longer recommended. The CloudWatch agent is the more modern, efficient, and supported solution for gathering memory metrics.