AWS Classroomnotes 22/Dec/2021

Uploading Apache Logs to CloudWatch

  • Create an ec2 instance with Amazon linux
  • Ensure IAM role is given to ec2 instance post launch
  • Now login into the ec2 instance and install apache server
sudo yum install httpd -y
sudo systemctl enable httpd
sudo systemctl start httpd
  • The path for the apache logs are /var/log/httpd/access_log and /var/log/httpd/error_log
  • Now lets install cloudwatch agent
sudo yum install amazon-cloudwatch-agent -y
  • Now configure cloudwatch agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard

Preview
* Continue with settings till you reach the log files section. configure for access logs
Preview
* Now configure for error logs
Preview
Preview
* Now we need to inform the cloudwatch agent whihc configuration to use
Preview

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
  • Now enable and start the cloudwatch agent
sudo systemctl enable amazon-cloudwatch-agent.service
sudo systemctl start amazon-cloudwatch-agent.service

Preview
* Sample script to generate traffic

#!/bin/bash
apache_url='http://18.237.201.9/'
while true
do
curl ${apache_url}
sleep 5
done

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube