Cloudwatch Agent Installation & Configuration
In this example, lets try to use Cloudwatch to monitor the WebApplication logs.
Step #1, is to create a service role, that allows the instance to connect with cloudwatch service. We will attach the AWS managed policy : CloudWatchAgentServerPolicy to the role.
Step #2, is to download the cloudwatch agent package for the instance and installation.
docs.aws.amazon.com/AmazonCloudWatch/latest..
In this example, will be using a Ubuntu machine.
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
Step#3, is to create the agent configuration file using the wizard.
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
In our case, we have a tomcat8 instance running on the server and would like to monitor the log file catalina.out located under /var/log/tomcat8 directory
The output of the wizard is written to a json file : config.json
The final step is to start the agent service.
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:config.json
Verify the cloudwatch agent logs at
On successful startup, the logs are now available in cloudwatch console.
To filter the logs, use Log Insight
Thus you can view the Application Deployment logs using Cloudwatch.