Rack middleware to send traffic logs to Fluentd
Switch branches/tags
Nothing to show
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/rack logging requests that throw errors Dec 7, 2018
spec import Nov 26, 2018
.gitignore adding badge Dec 1, 2018
.rspec import Nov 26, 2018
.rubocop.yml reorganizing a bit Nov 29, 2018
.ruby-gemset import Nov 26, 2018
.ruby-version import Nov 26, 2018
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Dec 7, 2018
Gemfile import Nov 26, 2018
Gemfile.lock adding badge Dec 1, 2018
LICENSE import Nov 26, 2018
README.md adding badge Dec 1, 2018
rack-fluentd-logger.gemspec fixing gemspec and updating readme Dec 1, 2018


Rack Fluentd Logger

Gem Version



gem 'rack-fluentd-logger'


gem install rack-fluentd-logger



require 'rack-fluentd-logger'

  name: 'your-app-log-name',
  host: 'your-fluentd-host',
  port: 24224

use Rack::FluentdLogger

run YourApplication

Configuration Options

name default description
name ENV['FLUENTD_NAME'] application name to use for fluentd logs
host ENV['FLUENTD_HOST'] fluentd server hostname/ip
port ENV['FLUENTD_PORT'] || 24_224 fluentd server port
json_parser ->(str) { JSON.parse(str) } used to parse response bodies if they are application/json
preprocessor ->(s) { s } callback for any additional processing/scrubbing of data before sending it off

Event Data

Events sent to fluentd have the following structure

  env: {
    # everything from the rack env that's an array/hash/string/number
  timestamp: Time.now, # current time when the log event is recorded
  response_time: 0.012, # length of time in seconds for response from rack
  code: 200, # http response code from rack app
  body: [], # body from rack app (when the content_type is json, it's parsed)
  headers: {} # http headers from the rack app