AWS CloudWatch – Install CloudWatch on EC2 Instance

Amazon CloudWatch

The CloudWatch agent will not work properly without the permissions configured.  This was the fastest way I found to get CloudWatch talking correctly.

Install Cloudwatch on the EC2 instance

  1. Install CloudWatch Agent
    sudo yum install amazon-cloudwatch-agent -y
  2. Install collectd (optional)
    You probably want collectd installed – https://www.collectd.org/.
    It looks like it allows for a bunch of customizations.
    https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-custom-metrics-collectd.html
  3. Navigate to the configuration wizard
    cd /opt/aws/amazon-cloudwatch-agent/bin/
  4. Run configuration wizard
    sudo ./amazon-cloudwatch-agent-config-wizard
  5. Start CloudWatch Agent
    sudo /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

Additional Commands

  • tail CloudWatch agent logs
    tail -f /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log
  • Restart CloudWatch agent
    sudo systemctl restart amazon-cloudwatch-agent

Leave a Reply

Your email address will not be published. Required fields are marked *