Project

General

Profile

Actions

Sending Foreman logs to a remote system using GELF » History » Revision 1

Revision 1/5 | Next »
Johan Sunnerstig, 03/04/2015 08:41 AM


Sending Foreman logs to a remote system using GELF

GELF
GELF is the Graylog Extended Log Format, a JSON based format. Read more about the format itself here:
https://www.graylog.org/resources/gelf-2/

Setting Foreman up to send logs to Graylog(or anything that can interpret GELF)
h3. Installing the gelf gem
Firstly you need the 'gelf' ruby gem. Add the following line to the file '_~foreman/bundler.d/gelf.rb_'
gem 'gelf', '1.4.0'

Now run '_su - foreman -c bundle_' to install the gem and any dependencies. When it's done you should see a line like so:
Your bundle is complete! It was installed into ./vendor

Updating your configuration
Now it's time to make Foreman use it. Edit '_~foreman/config/environments/production.rb_' and find the line with a logger example.
You need to add one of your own like this:
  # Use a different logger for distributed setups
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
  config.logger = GELF::Logger.new("your.graylog.server.com", 12201, "WAN", { :facility => "foreman" })

The facility field can be (almost) anything you feel like, preferably something descriptive.

Now restart your Foreman instance and you should be good to go.

Updated by Johan Sunnerstig almost 10 years ago · 5 revisions