Step 1 – Create Ubuntu EC2 instance and prep for CloudWatch Agent installation
sudo apt update
sudo apt install collectd -y
sudo apt install awscli -y
aws configure {configure region}
Step 2 – Attach IAM role to Ubuntu instance
IAM>Role>Choose EC2>Choose policiy CloudWatchFullAccess
Instances>Select instance>Actions>Security>Modify IAM role
Step 3 – Install CloudWatch Agent
sudo chown ubuntu:ubuntu -R /opt
cd /opt
mkdir software
cd software
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
Step 4 – Configure CloudWatch Agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
- Use default options
- Select Advanced for metrics config
- Collect logs from /var/log/syslog, additional files no, SSM store no
Step 5 – Start the CloudWatch Agent for the first time
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
Other agent commands:
To stop: sudo service amazon-cloudwatch-agent stop
To check status: sudo service amazon-cloudwatch-agent status
To start: sudo service amazon-cloudwatch-agent start
Agent logs:
cd /opt/aws/amazon-cloudwatch-agent/logs/
ls -al
Step 6 – Verify CloudWatch Setup
- Navigate to CloudWatch on the AWS console
- Click on Log groups under Logs
- You should see “syslog” under Log group
1 thought on “QuickGuide: Amazon CloudWatch Setup”