Removing the CloudWatch Logs Agent

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:

[adsense]

    1. Stop the awslogs service:
      # service awslogs stop
    2. Remove the /var/awslogs directory and its contents:
      # rm -rf /var/awslogs
    3. Remove /etc/init.d/awslogs:
      # rm -rf /etc/init.d/awslogs
    4. Remove the setup script:
      # rm -rf <location of script>/awslogs-agent-setup.py
    5. 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”.

Subscribe to my feed either by E-mail or by RSS to receive updates as they happen.

Can you improve on any of the tips I’ve discussed here? If you can let me know in the comments.

  • ssanchez

    How can install again the agent on mi EC2 Amazon Linux. Everytime that I try to install with this command sudo yum install -y awslogs it show me this message
    Package awslogs-1.1.2-1.10.amzn1.noarch already installed and latest version
    Nothing to do

    But the agent doesn’t work. Can you help me?

  • Davide Del Grande

    Hi, at least on Ubuntu 14.04, I perform full removal with (as root ofc):

    service awslogs stop
    update-rc.d awslogs disable
    update-rc.d -f awslogs remove

    pip uninstall awslogs
    rm -rf /var/awslogs
    rm -f /var/log/awslogs-agent-setup.log
    rm -f /var/log/awslogs.log
    rm -f /etc/logrotate.d/awslogs
    rm -f /etc/cron.d/awslogs
    rm -f /etc/cron.d/awslogs_log_rotate
    rm -f /etc/init.d/awslogs

    rm (location of setup script)

    HTH,Bye.