How to Add RAM Metrics to EC2 Instances

Learn how to add RAM metrics to AWS EC2 instances for better performance monitoring. This step-by-step guide covers enabling CloudWatch custom metrics to track memory usage effectively.

Step 1: Create and Configure IAM Role

Step 2: Download and Install CloudWatch Agent

				
					ssh -i /path/to/key.pem ec2-user@<EC2_IP>
				
			

Example: ssh -i “~/.ssh/gro-ec2-ohio.pem” [email protected]

				
					cd /tmp
				
			
				
					wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb

				
			
				
					sudo dpkg -i amazon-cloudwatch-agent.deb
				
			
				
					dpkg -l | grep amazon-cloudwatch-agent
				
			

Step 3: Configure and Initialize CloudWatch Agent

				
					sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
				
			

Once completed, the configuration will be saved at: /opt/aws/amazon-cloudwatch-agent/bin/config.json

				
					sudo amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
				
			

This will Apply the configuration and Start the CloudWatch Agent as a service.

				
					sudo systemctl status amazon-cloudwatch-agent
				
			

You should see anĀ Active (running) status if it’s running.

				
					sudo systemctl enable amazon-cloudwatch-agent
				
			

Step 4: Add and Verify Metrics in CloudWatch

Elementor Logo

Elementor Credentials

Crocoblock logo

Crocoblock Subscription Key