AWS Classroomnotes 21/Dec/2021

Amazon CloudWatch agent

  • This agent is an application that runs as a daemon or background application that collects and sends the logs to cloud watch
  • Lets create an amazon linux ec2 instance and configure the cloudwatch agent
  • Install Cloud watch agent Refer Here
    sudo yum install amazon-cloudwatch-agent -y
    sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
  • Refer Here for log agent configuration
  • Once we run the wizard and then try to answer questions then a config file will be created at /opt/aws/amazon-cloudwatch-agent/bin/config.json
    Preview
  • For this ec2 instance to send logs to AWS we need to give permissions
  • Create an IAM Role => This is applicable to ec2 instances only
  • Create an IAM user and configure this => This can be done for ec2 instances as well as on-premises instances
  • Lets create an IAM Role
    Preview
    Preview
    Preview
    Preview
    Preview
    Preview
    Preview
  • Now lets apply this role to the ec2 instance
    Preview
    Preview
  • Now lets install httpd on this ec2 instance
    sudo yum install httpd -y
    sudo systemctl enable httpd.service
    sudo systemctl start httpd.service
  • Now start the cloud watch agent
    sudo amazon-cloudwatch-agent-ctl -a start
  • Try to write some shell which will continuously access your apache server
    bash
    apache_url='http://34.209.194.214'
    while true
    do
    curl ${apache_url}
    sleep 5
    done
  • Next Steps: Lets troubleshoot the issue w.r.t to log streams not getting created.

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner