.ebextensions/cloudwatch.config
# per https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-cw.html
files:
"/opt/aws/amazon-cloudwatch-agent/bin/config.json":
mode: "000644"
owner: root
group: root
content: |
{
"agent": {
"metrics_collection_interval": 300
},
"metrics": {
"namespace": "System/Linux",
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"InstanceId":"${aws:InstanceId}"
},
"metrics_collected": {
"mem": {
"measurement": [
"mem_available",
"mem_used",
"mem_used_percent"
]
},
"disk": {
"resources": ["/"],
"measurement": [
"disk_free",
"disk_used",
"disk_used_percent"
]
},
"procstat": [
{
"pid_file": "/var/pids/worker.pid",
"measurement": [
"cpu_usage",
"memory_rss"
]
}
]
}
}
}
container_commands:
start_cloudwatch_agent:
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json