Additional logs and metrics can be capture by installing and configuring the CloudWatch agent.
Navigate to Systems Manager Parameter Store
View the CloudWatch Configuration
We have created a parameter that will be used to configure the CloudWatch agent for the application. The code is displayed below for easy reading.
{
"logs": {
"logs_collected": {
"files": {
"collect_list": [{
"file_path": "/var/log/messages",
"log_group_name": "messages"
}, {
"file_path": "/var/log/demsg",
"log_group_name": "dmesg"
}, {
"file_path": "/var/log/boot.log",
"log_group_name": "boot.log"
}, {
"file_path": "/opt/imagetrends/log/application.log",
"log_group_name": "application.log"
}, {
"file_path": "/opt/imagetrends/log/production.log",
"log_group_name": "production.log"
}]
}
}
},
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"cpu": {
"measurement": ["cpu_usage_idle", "cpu_usage_iowait", "cpu_usage_user", "cpu_usage_system"],
"metrics_collection_interval": 60,
"resources": ["*"],
"totalcpu": false
},
"disk": {
"measurement": ["used_percent", "inodes_free"],
"metrics_collection_interval": 60,
"resources": ["*"]
},
"diskio": {
"measurement": ["io_time"],
"metrics_collection_interval": 60,
"resources": ["*"]
},
"mem": {
"measurement": ["mem_used_percent"],
"metrics_collection_interval": 60
},
"statsd": {
"metrics_aggregation_interval": 60,
"metrics_collection_interval": 10,
"service_address": ":8125"
},
"swap": {
"measurement": ["swap_used_percent"],
"metrics_collection_interval": 60
}
}
}
}
Install CloudWatch
You should now see two instances having CloudWatch installed. If you don’t see any targets, repeat the previous steps and ensure the tags match your instances.
Configure CloudWatch
You should now see two instances having CloudWatch configured. If you don’t see any targets, repeat the previous steps and ensure the tags match your instances.
You have now configured your environment to provide telemetry with CloudWatch logging and metrics.