Amazon provide really detailed instructions for installing the CloudWatch logs agent on existing servers: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/QuickStartEC2Instance.html. But what they do not provide is instructions for removing it if/when you no longer require it.
Therefore I have provided instructions below for removing the CloudWatch logs agent from one of the CentOS servers at work:
- Stop the awslogs service:
# service awslogs stop
- Remove the /var/awslogs directory and its contents:
# rm -rf /var/awslogs
- Remove /etc/init.d/awslogs:
# rm -rf /etc/init.d/awslogs
- Remove the setup script:
# rm -rf <location of script>/awslogs-agent-setup.py
- 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”.
Can you improve on any of the tips I’ve discussed here? If you can let me know in the comments.