DEV Community

Puneet Jena
Puneet Jena

Posted on

"Unified Agent Installation and Log Monitoring on Amazon EC2 Using CloudWatch: A Step-by-Step Guide"

1.Sign in to the AWS Management Console:
2.Log in to your AWS account using your credentials.
3.Launch an EC2 Instance:
4.First of all create required IAM roles for the EC2 instances to be able to send metrics to cloudwatch
In the list of policies while creating IAM Role for EC2 Instance, select the check box next to CloudWatchAgentServerPolicy. Use the search box to find the policy, if necessary.


5.Download the CloudWatch Unified Agent:
wget https://s3.amazonaws.com/amazoncloudwatch-agent/your_os_architecture/latest/amazon-cloudwatch-agent.rpm
6.Install the CloudWatch Agent:
sudo rpm -U ./amazon-cloudwatch-agent.rpm
7.Configure the CloudWatch Agent:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
8.Start the 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

choose these all options to set-up

Steps

First let’s install and start a web server to generate some web traffic logs. This commmad works for RHEL and Amazon Linux.
sudo yum install httpd -y
sudo service httpd start

  1. Copy the public IP of the instance you’re on and paste that in a web browser and refresh a few times.  see a new custom metric in cloud watch

Top comments (0)