diff --git a/tasks/config-collect.json b/tasks/config-collect.json new file mode 100644 index 0000000..4facac3 --- /dev/null +++ b/tasks/config-collect.json @@ -0,0 +1,40 @@ + { + "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" + } + } + } + } diff --git a/tasks/config.json b/tasks/config.json new file mode 100644 index 0000000..a65bcc3 --- /dev/null +++ b/tasks/config.json @@ -0,0 +1,70 @@ +{ + "agent": { + "metrics_collection_interval": 60, + "run_as_user": "cwagent" + }, + "metrics": { + "aggregation_dimensions": [ + [ + "InstanceId" + ] + ], + "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 + } + } + } +} diff --git a/tasks/main.yml b/tasks/main.yml index 26a50a7..192148b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,7 @@ -- name: Install collectd - apt: - name: collectl - state: present +#- name: Install collectd +# apt: +# name: collectl +# state: present - name: Install CloudWatch agent for Ubuntu apt: @@ -12,47 +12,7 @@ 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" - } - } - } - } + src: config.json - 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