A structured logger class for Fluentd. (mruby)
Ruby Makefile
Switch branches/tags
Nothing to show
Clone or download
Latest commit 99303a1 Oct 29, 2015

README.md

mruby-fluent-logger

mruby-fluent-logger (a.k.a. fluent-logger-mruby) is a structured logger class for Fluentd.

Requirements

Articles

Install

Let's add these gem line into build_config.rb and execute rake to build mruby.
Another way to use this mrbgems, you can generate a build configuration with mgem.

for Unix/Linux/MacOSX

MRuby::Build.new do |conf|
  ...snip...

  conf.gem :git => 'https://github.com/iij/mruby-io.git'
  conf.gem :git => 'https://github.com/iij/mruby-socket.git'
  conf.gem :git => 'https://github.com/iij/mruby-pack.git'
  conf.gem :git => 'https://github.com/suzukaze/mruby-msgpack.git'
  conf.gem :git => 'https://github.com/mattn/mruby-http.git'
  conf.gem :git => 'https://github.com/y-ken/mruby-simplehttp-socket.git'
  conf.gem :git => 'https://github.com/matsumoto-r/mruby-httprequest.git'
  conf.gem :git => 'https://github.com/y-ken/fluent-logger-mruby.git'

  ...snip...
end

for Multi Platform

install required package.

MRuby::Build.new do |conf|
  ...snip...

  conf.gem :git => 'https://github.com/iij/mruby-pack.git'
  conf.gem :git => 'https://github.com/suzukaze/mruby-msgpack.git'
  conf.gem :git => 'https://github.com/mattn/mruby-uv.git'
  conf.gem :git => 'https://github.com/mattn/mruby-http.git'
  conf.gem :git => 'https://github.com/matsumoto-r/mruby-simplehttp.git'
  conf.gem :git => 'https://github.com/matsumoto-r/mruby-httprequest.git'
  conf.gem :git => 'https://github.com/y-ken/fluent-logger-mruby.git'

  ...snip...
end

Usage

  • in_http (http input plugin).
  • in_forward (forward Input Plugin)(Required protocol argument.).

Simple

log = Fluent::Logger.new()
log.post('myapp.access', {"agent"=>"foo"})

# output: myapp.access {"agent":"foo"}
log = Fluent::Logger.new(nil, :host=>'127.0.0.1', :port=>8888)
log.post('myapp.access', {"agent"=>"foo"})

# output: myapp.access {"agent":"foo"}

with protocol argument(:protocol => http).

log = Fluent::Logger.new(nil, :protocol=>'http', :host=>'127.0.0.1', :port=>'8888')
log.post('test.hoge', {"message"=>"foo"})

# output: test.hoge: {"message":"foo"}

Singleton

It's welcome pull requesting because it doesn't supported yet.

Tag prefix

log = Fluent::Logger.new('myapp', :host=>'127.0.0.1', :port=>8888)
log.post('access', {"agent"=>"foo"})

# output: myapp.access {"agent":"foo"}

forward to 24224

Required protocol argument.

log = Fluent::Logger.new(nil, :protocol=> 'tcp', :host=>'127.0.0.1', :port=>'24224')
log.post('test.hoge', {"message"=>"foo"})

# output: test.hoge: {"message":"foo"}

with Tag prefix.

log = Fluent::Logger.new("mruby.tcp", :protocol=>'tcp', :host=>'127.0.0.1', :port=>'24224')
log.post('test.hoge', {"message"=>"foo"})

# output: mruby.tcp.test.hoge: {"message":"foo"}

TODO

Pull requests are very welcome!! I'm awaiting pull requests like below.

  • support fluentd forward input (port 24224)

Copyright

Copyright © 2013- Kentaro Yoshida (@yoshi_ken)

License