60 lines
1.6 KiB
YAML
60 lines
1.6 KiB
YAML
- name: Install collectd
|
|
apt:
|
|
name: collectd
|
|
state: present
|
|
|
|
- name: Install CloudWatch agent for Ubuntu
|
|
apt:
|
|
deb: https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
|
|
state: present
|
|
|
|
- name: Create basic CW agent config
|
|
copy:
|
|
dest: /opt/aws/amazon-cloudwatch-agent/bin/config.json
|
|
backup: yes
|
|
content: |
|
|
{
|
|
"agent": {
|
|
"metrics_collection_interval": 60,
|
|
"run_as_user": "cwagent"
|
|
},
|
|
"metrics": {
|
|
"namespace": "CWAgent",
|
|
"append_dimensions": {
|
|
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
|
|
"ImageId": "${aws:ImageId}",
|
|
"InstanceId": "${aws:InstanceId}",
|
|
"InstanceType": "${aws:InstanceType}"
|
|
},
|
|
"metrics_collected": {
|
|
"collectd": {
|
|
"metrics_aggregation_interval": 60
|
|
},
|
|
"disk": {
|
|
"measurement": [
|
|
"used_percent"
|
|
],
|
|
"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"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
- name: Enable and start agent
|
|
shell: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
|
|
|