Tanzu CloudHealth can use AWS CloudWatch to collect custom metrics from EC2 instances for performance and rightsizing reports.
Please follow the following guide to configure the AWS CloudWatch Custom Metrics.
AWS
To configure CloudWatch custom metrics, Follow the below guide.
Enabling CloudWatch option in CloudHealth:
Installing CloudWatch Agents at AWS:
AWS CloudWatch Metrics Namespace supported in CloudHealth:
CWAgent
System/Linux
System/Windows
Supported CloudWatch Metrics:
Metrics for Linux Instances |
mem_total |
mem_used_percent |
mem_free |
swap_used |
swap_used_percent |
swap_free |
disk_total |
disk_used |
Metrics for Windows Instances |
Memory % Committed Bytes In Use |
Memory Available MBytes |
Paging File % Usage |
LogicalDisk % Free Space |
Metrics for Linux Instances Published by Script |
MemoryUsed |
MemoryUtilization |
MemoryAvailable |
SwapUsed |
SwapUtilization |
DiskSpaceUsed |
DiskSpaceUtilization |
CloudWatch Agent Configuration JSON
For Linux:
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "root"
},
"metrics": {
"namespace": "CWAgent",
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
},
"metrics_collected": {
"disk": {
"measurement": [
"used",
"total"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"mem": {
"measurement": [
"free",
"used_percent",
"total"
],
"metrics_collection_interval": 60
},
"swap": {
"measurement": [
"free",
"used",
"used_percent"
],
"metrics_collection_interval": 60
}
}
}
}
To deploy the configuration, copy the above configuration to a JSON file called cw.json.
run the following command (assuming the cw.json
file is under the /home/ec2-user/cw.json
path)
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/home/ec2-user/cw.json
To validate the CloudWatch service is running and the configuration, run the following command.
systemctl | grep cloudwatch
sudo cat /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_cw.json
For Windows:
{
"metrics": {
"namespace": "CWAgent",
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
},
"metrics_collected": {
"LogicalDisk": {
"measurement": [{
"name": "% Free Space",
"unit": "Percent"
}],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Memory": {
"measurement": [{
"name": "% Committed Bytes In Use",
"unit": "Percent"
}],
"metrics_collection_interval": 60
},
"Paging File": {
"measurement": [{
"name": "% Usage",
"unit": "Percent"
}],
"metrics_collection_interval": 60,
"resources": [
"*"
]
}
}
}
}
To deploy this configuration file to Windows system, copy the above configuration content to a file called cw.json then follow the below Powershell command (assuming you saved the cw.json under "C:\Users\Administrator\Downloads\cw.json"
& "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:C:\Users\Administrator\Downloads\cw.json
To validate the service and configuration you can run the following command.Get-service "*cloudwatch*"
type C:\ProgramData\Amazon\AmazonCloudWatchAgent\Configs\file_cw.json