diff --git a/.ebextensions/cloudwatch.config b/.ebextensions/cloudwatch.config index b024e7c8..3ff33c1f 100644 --- a/.ebextensions/cloudwatch.config +++ b/.ebextensions/cloudwatch.config @@ -1,26 +1,28 @@ -packages: - yum: - perl-DateTime: [] - perl-Sys-Syslog: [] - perl-LWP-Protocol-https: [] - perl-Switch: [] - perl-URI: [] - perl-Digest-SHA: [] - -sources: - /opt/cloudwatch: http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip - +files: + "/opt/aws/amazon-cloudwatch-agent/bin/config.json": + mode: "000600" + owner: root + group: root + content: | + { + "agent": { + "metrics_collection_interval": 60, + "run_as_user": "root" + }, + "metrics": { + "namespace": "System/Linux", + "append_dimensions": { + "AutoScalingGroupName": "${aws:AutoScalingGroupName}" + }, + "metrics_collected": { + "mem": { + "measurement": [ + "mem_used_percent" + ] + } + } + } + } container_commands: - 01-setupcron: - command: | - echo '*/5 * * * * root perl /opt/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl `{"Fn::GetOptionSetting" : { "OptionName" : "CloudWatchMetrics", "DefaultValue" : "--mem-util --disk-space-util --disk-path=/" }}` >> /var/log/cwpump.log 2>&1' > /etc/cron.d/cwpump - 02-changeperm: - command: chmod 644 /etc/cron.d/cwpump - 03-changeperm: - command: chmod u+x /opt/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl - -option_settings: - "aws:autoscaling:launchconfiguration" : - IamInstanceProfile : "aws-elasticbeanstalk-ec2-role" - "aws:elasticbeanstalk:customoption" : - CloudWatchMetrics : "--mem-util --mem-used --mem-avail --disk-space-util --disk-space-used --disk-space-avail --disk-path=/ --auto-scaling" + 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