How to install and configure the CloudWatch logs agent on a EC2 Ubuntu linux server instance?

by XDK 16. August 2019 20:58

Steps:

 1. Create and Attach an IAM role with "CloudWatchFullAccess" policy to the EC2 instance as follows

  • Open the IAM console --> Create Role --> apply.
  • Attach the created Role to the EC2 instance.

2. To install and configure CloudWatch Logs on an existing Ubuntu Server instance

  • Connect to the EC2 instance,
  • On EC2 instance, run the following commands before installing CloudWatch Log

         sudo apt update
         sudo apt install python3

  • To install and configure CloudWatch Logs directly from the internet

         curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O

  • Run the following command to setup system and custom application logs

        sudo python ./awslogs-agent-setup.py --region us-east-1