Redirecting Sidekiq logs


Background jobs. Logging.

Sidekiq + Graylog = LOVE.

Ruby GEM for this article: https://github.com/layervault/sidekiq-gelf-rb

Adding gem to your project

gem "sidekiq-gelf"

Run:

bundle install

Edit configuration files

Edit your sidekiq.rb initializer. Add your Graylog instance IP address and your application name (will be used as ID in Graylog Dashboard).

Sidekiq.configure_server do |config|
  Sidekiq::Logging::GELF.hook!('127.0.0.1', 12201, 'LAN', facility: "my-application")
end

By default Sidekiq will continue using two outputs in this case: default to sidekiq.log file and new GELF based.

Configure Graylog

Add new INPUT (or use existing one) at your Graylog instance with GELF UDP type.

graylog

graylog

Check details for each job:

graylog

Done!