Not only can AWS Cloudwatch alert you of problems with your resources, it can also store your log files and make them accesible in the AWS web interface. To make AWS Cloudwatch Logs work you’ll need to install a small agent on your EC2 instances. Currently AWS has support for CentOS, RHEL, Amazon Linux and Ubuntu 12.04 and 14.04, among some other distributions.
The newest LTS version of Ubuntu, 16.04, isn’t on the list of supported versions yet. As Ubuntu switched to Systemd for their default init system you’ll run into some trouble getting the Cloudwatch Logs Agent service started.
Installing Cloudwatch Logs Agent
Amazon provides a small installer for the agent.
Where MY_REGION is the region your EC2 instances are running in, for example eu-west-1.
Getting the service to run
Because Amazon doesn’t provide support for Ubuntu 16.04 yet there also isn’t a Systemd unit file yet. I created one myself.
Make sure the service will start itself on boot and start the Agent.
To make installing and configuring the agent just a little easier I made an Ansible role available that will do all of this for you. You can pull the code from the GitHub repository. Of course improvements are welcome via a pull request.