9

Only after using sudo python ./awslogs-agent-setup.py --region us-east-1 on my Amazon Linux AMI, I found this tidbyte of Caution from AWS docs:

Do not update the CloudWatch Logs agent using the RPM installation method if you previously used the Python script to install the agent. Doing so may cause configuration issues that prevent the CloudWatch Logs agent from sending your logs to CloudWatch.

Now, how can I uninstall the python version to use the RPM installation?

E.A.T
  • 848
  • 11
  • 24

2 Answers2

17

There is a writeup about removing awslogs on CentOS, I guess you can apply this on Amazon Linux as well. I don't think there is an easier way than doing it manually.

Edited as the link above is not reachable:

These steps should be executed:

#Stop the awslogs service.
service awslogs stop

#Remove cloud watch related files.
rm -rf /var/awslogs
rm /etc/cron.d/awslogs*
rm /etc/init.d/awslogs
rm /var/log/awslogs*
rm -rf /home/ubuntu/awslogs-agent-setup.py

Then restart the server if required.

The CloudWatch logs agent should now be removed from the system. Ensure you log into the CloudWatch AWS Console to remove the log group: AWS Console -> CloudWatch -> Logs -> Select the Log Group and click on “Delete Log Group”.

peetasan
  • 848
  • 11
  • 17
4

There is another work-around for removing the Cloudwatch agent permanently. If you installed the package using rpm, we can use yum or apt-get to remove the package permanently.

sudo yum remove amazon-cloudwatch-agent -y

or

sudo apt-get remove amazon-cloudwatch-agent -y
mjuarez
  • 16,372
  • 11
  • 56
  • 73
Hrudhay
  • 41
  • 1
  • 1
    There is no package called amazon-cloudwatch-agent at all – papalagi Feb 19 '20 at 00:11
  • https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html. if you have installed cloudwatch agent on a ec2 instance using this tutorial, the above commands helps us to remove it – Hrudhay Jun 02 '20 at 20:45
  • 1
    The OP asks how to remove awslogs agent, not amazon-cloudwatch-agent. Two different packages. – prophoto Jul 27 '20 at 14:47