Sending Foreman logs to a remote system using GELF » History » Version 1
Johan Sunnerstig, 03/04/2015 08:41 AM
1 | 1 | Johan Sunnerstig | h1. Sending Foreman logs to a remote system using GELF |
---|---|---|---|
2 | |||
3 | h2. GELF |
||
4 | GELF is the Graylog Extended Log Format, a JSON based format. Read more about the format itself here: |
||
5 | https://www.graylog.org/resources/gelf-2/ |
||
6 | |||
7 | h2. Setting Foreman up to send logs to Graylog(or anything that can interpret GELF) |
||
8 | h3. Installing the gelf gem |
||
9 | Firstly you need the 'gelf' ruby gem. Add the following line to the file '_~foreman/bundler.d/gelf.rb_' |
||
10 | <pre><code class="ruby"> |
||
11 | gem 'gelf', '1.4.0' |
||
12 | </code></pre> |
||
13 | |||
14 | Now run '_su - foreman -c bundle_' to install the gem and any dependencies. When it's done you should see a line like so: |
||
15 | _Your bundle is complete! It was installed into ./vendor_ |
||
16 | |||
17 | h3. Updating your configuration |
||
18 | Now it's time to make Foreman use it. Edit '_~foreman/config/environments/production.rb_' and find the line with a logger example. |
||
19 | You need to add one of your own like this: |
||
20 | <pre><code class="ruby"> |
||
21 | # Use a different logger for distributed setups |
||
22 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) |
||
23 | config.logger = GELF::Logger.new("your.graylog.server.com", 12201, "WAN", { :facility => "foreman" }) |
||
24 | </code></pre> |
||
25 | The facility field can be (almost) anything you feel like, preferably something descriptive. |
||
26 | |||
27 | Now restart your Foreman instance and you should be good to go. |