Installing CloudWatch Agent on amazon linux 1

Abstract::

  • Add CloudWatchAgentServerPolicy policy to EC2 instance IAM role
  • Install CloudWatch Agent ( amazon linux 1 ):

https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm

  • Create a file /opt/aws/amazon-cloudwatch-agent/bin/config.json and add custom metrics needed for monitoring. Example:
{
    "metrics": {
        "metrics_collected": {
            "mem": {
                "measurement": [
                    "mem_used_percent"
                ],
                "metrics_collection_interval": 60
            },
            "disk": {
              "measurement": [
                "disk_used_percent"
              ],
              "metrics_collection_interval": 60
            }
        }
    }
}

  • Start cloudwatch agent.

sudo /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

CW_Agent IAM roles

CW_agent install

CW_agent metric collection

CW_agent to monitor RAM: blog

CW_agent dockerfile