How To Setup AWS Logs Agent on Ubuntu 16.04 Instance

This tutorial will guide you through the steps for configuring awslogs agent on an EC2 Ubuntu 16.04 server instance.

Install and Configure AWSLogs

Step1: Update the system and install python.

Step2: Download the latest agent installation script.

Step3: Run the agent setup command with the region parameter. Replace the eu-west-2 with the aws region code where you are operating.

Fill in the required parameters when prompted.

Setup AWSLogs as a service

There is no support for creating awslogs as a service in Ubuntu 16.04. So we need to create our own systemd unit file for running it as a service.

1. cd into /etc/systemd/system directory.

2. Create a file named awslogs.service

3. Copy the following content on the awslogs.service file.

4. Now start the agent using the following command.

READ  How To Setup GUI For Amazon EC2 Linux Instance

To stop and restart, you can use the following commands.

5. To enable awslogs service on boot, execute the following command.

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.

1 Comment

  1. Chris Reply

    Hey DevopsCube Team!

    Thanks for the great article. It fails on the last step for me on the Ubuntu EC2 instance I’m using. Error output is this:

    Synchronizing state of awslogs.service with SysV init with /lib/systemd/systemd-sysv-install…
    Executing /lib/systemd/systemd-sysv-install enable awslogs
    insserv: warning: current start runlevel(s) (0 1 2 3 4 5 6) of script awslogs' overrides LSB defaults (2 3 4 5).
    insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script
    awslogs’ overrides LSB defaults (0 1 6).
    insserv: warning: current start runlevel(s) (0 1 2 3 4 5 6) of script `awslogs’ overrides LSB defaults (2 3 4 5).
    insserv: can not symlink(../init.d/awslogs, ../rc2.d/S01awslogs): File exists
    insserv: can not symlink(../init.d/awslogs, ../rc3.d/S01awslogs): File exists
    insserv: can not symlink(../init.d/awslogs, ../rc4.d/S01awslogs): File exists
    insserv: can not symlink(../init.d/awslogs, ../rc5.d/S01awslogs): File exists

    Any ideas what the cause may be?

    I previously set this up via another method, but am having trouble changing the configuration. See here for the instructions I used: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/QuickStartEC2Instance.html

    Best,
    Chris

Leave a Reply

Your email address will not be published. Required fields are marked *