Using Loggly On Elastic Beanstalk

2015-07-19

This week I had to configure a Rails app running on Elastic Beanstalk to use Loggly. Since I don’t want anyone to suffer the Elastic Beanstalk documentation more than is necessary, I’ve written this short tutorial should you find yourself tasked with the same challenge. It assumes you already have a Rails app running on Elastic Beanstalk and a general understanding of Rails apps.

Configure App

Add the syslogger gem to your Gemfile.

In config/environments/production.rb configure your app to use Syslogger for logging. Replace "your-app-name" with, you guessed it, the name of your application. This allows you to easily see logs from your app in the Loggly web interface using source groups, which is especially useful if you’re using Loggly to aggregate logs from multiple apps.

Create Loggly Account

Go sign up for a Loggly account and create a customer token.

Configure Container Environment

Go to the Amazon AWS Console and add your Loggly account name and customer token to your Elastic Beanstalk app’s environment using the LOGGLY_ACCOUNT and LOGGLY_AUTH property names.

Customise Container

Add the following configuration to loggly.config in the .ebextensions directory in the root of your app.

This YAML file downloads Loggly’s own syslog configuration script and sets up your container to send your system logs to Loggly. You can audit this script at loggly/install-script.

Wrap Up

Re-deploy your app to Elastic Beanstalk and watch as your logs begin appearing in Loggly.