Example AWS Cloudwatch Agent Config
Configuration file location:
cat /opt/aws/amazon-cloudwatch-agent/bin/config.json
Configuration File
{
"agent": {
"metrics_collection_interval": 600,
"run_as_user": "root"
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/var/log/nginx/access_json.log",
"log_group_name": "nginx_access_json",
"log_stream_name": "nginx_access_json"
},
{
"file_path": "/var/www/html/app/storage/logs/laravel.log",
"log_group_name": "log_app",
"log_stream_name": "error_logs"
},
{
"file_path": "/var/www/html/app/storage/logs/worker.log",
"log_group_name": "log_app",
"log_stream_name": "worker_logs"
}
]
}
},
"force_flush_interval": 900,
"log_stream_name": "my_log_stream_name"
},
"metrics": {
"aggregation_dimensions": [
[
"AutoScalingGroupName"
]
],
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"mem": {
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60
}
}
}
}
Configuration Sections
Section | Purpose |
---|---|
agent | Basic agent settings and intervals |
logs | Log collection configuration |
metrics | Metrics collection and dimensions |
Monitored Logs
- Nginx access logs
- Laravel application logs
- Worker process logs
Collected Metrics
- Memory usage percentage
- Auto Scaling group metrics
- Instance-specific metrics