These instructions allow you to collect a variety of performance metrics from you cluster nodes, sampled every 60 seconds, including:
- cpu usage
- memory usage
- disk usage
- network usage
Note: metrics collected by the CloudWatch agent are billed as custom metrics.
The target OS is Ubuntu (x86_64), you'll need aws-cli
and unzip
installed.
Follow the 12-step guide on AWS docs from the "To create the IAM role necessary for each server to run the CloudWatch agent" paragraph.
You won't be using Systems Manager so ignore the AmazonSSMManagedInstanceCore
policy, instead use CloudWatchAgentServerPolicy
only.
Open the IAM console at https://console.aws.amazon.com/iam/ and find the Instance profile ARN
of the Role created in the step above (example: arn:aws:iam::xxxxxxxxxx:instance-profile/ProtocolLabs-CloudWatchAgentServerRole
).
Save it in export AWS_INSTANCE_PROFILE_ARN="<your-instance-profile-arn>"
.
Now run the following command for each EC2 instance in your cluster.
Replace <your-ec2-instance-ID>
with the right Instance ID
, you can find that value either in the AWS console or by running ec2metadata --instance-id
from within the host.
aws ec2 associate-iam-instance-profile \
--instance-id "<your-ec2-instance-ID>" \
--iam-instance-profile Arn=${AWS_INSTANCE_PROFILE_ARN}
Run the following commands on each host, this way you'll be able to fetch metrics from the whole cluster.
Make sure you have the AWS_REGION
environment variable set up.
wget "https://s3.${AWS_REGION}.amazonaws.com/amazoncloudwatch-agent-${AWS_REGION}/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb"
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
sudo apt update
sudo apt install -y collectd
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:amazon-cloudwatch-agent.json