Setting up CloudWatch Agent on AWS EC2
This guide describes how to set up AWS CloudWatch Agent in CloudXper.
This setting allows you to check Memory Utilization in CloudXper.
AWS CloudWatch Agent Configuration Guide
Refer to AWS official documentation: Collecting Metrics, Logs, and Traces Using the CloudWatch Agent - Amazon CloudWatch
How CloudXper Collects Memory Metrics
AWS does not provide memory-related metrics as default metrics.
You must install CloudWatch on EC2 to view Memory metrics.
When CloudXper receives the Memory metrics, Based on InstanceIdIt can only be received as (Dimension = InstanceId).
Metrics to collect
Linux: “mem_used_percent”
Window: “Memory % Committed Bytes In Use”
Setup Guide
CloudWatch Agent Config settings required
Modify the Config Default file (the path may vary depending on your OS, so check it)
Modify the /opt/aws/amazon-cloudwatch-agent/amazon-cloudwatch-agent.d/default file (sudo permission required)Linux
If you need to view data by combination of InstanceId, ImageId, InstanceType, and AutoscalingGroupName, modify as follows:
{ "agent": { "run_as_user": "cwagent" }, "metrics": { "metrics_collected": { "mem": { "measurement": [ "mem_used_percent" ] }, "disk": { "measurement": [ "used_percent" ], "resources": [ "*" ] } }, "append_dimensions": { "ImageId": "${aws:ImageId}", "InstanceId": "${aws:InstanceId}", "InstanceType": "${aws:InstanceType}", "AutoScalingGroupName": "${aws:AutoScalingGroupName}" }, "aggregation_dimensions": [ [ "InstanceId" ], [ "InstanceId", "ImageId", "InstanceType", "AutoScalingGroupName" ] ] } }If you only want to view data in CloudXper, modify it as follows:
{ "agent": { "run_as_user": "cwagent" }, "metrics": { "metrics_collected": { "mem": { "measurement": [ "mem_used_percent" ] }, "disk": { "measurement": [ "used_percent" ], "resources": [ "*" ] } }, "append_dimensions": { "InstanceId": "${aws:InstanceId}" } } }
Window
To-BE Write
Stop the CloudWatch agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a stop
Starting the CloudWatch agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a start
Check CloudWatch agent status
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
If it appears as below, it is normal
{ "status": "running", "starttime": "시작시간", "configstatus": "configured", "cwoc_status": "stopped", "cwoc_starttime": "", "cwoc_configstatus": "not configured", "version": "1.247347.3b250378" }Confirm actual collection
If it exists in the CWAgent Namespace, it is normal.
If you see a part that is only searched by InstanceId, it is normal.
If you see Memory Data, it's normal