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