Skip to content

Instantly share code, notes, and snippets.

@kiyoto
Created December 19, 2014 02:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kiyoto/e22c3238aced02b2547a to your computer and use it in GitHub Desktop.
Save kiyoto/e22c3238aced02b2547a to your computer and use it in GitHub Desktop.
require 'fluent-logger'
# specify the host and port to forward data to
logger = Fluent::Logger.new(nil, :host => "localhost", :port => 24224)
fn = ARGV[0]
fh = File.new(fn)
msgpack_unpacker = MessagePack::Unpacker.new(fh)
begin
msgpack_unpacker.each do |time, record|
# post data with the tag "t"
logger.post_with_time('t', record, time)
end
ensure
fh.close
end
@RahulGojame
Copy link

If the message does not contain time and have tag name, object id and message then use the following code.

require 'fluent-logger'

specify the host and port to forward data to

logger = Fluent::Logger.new(nil, :host => "localhost", :port => 24222)
fn = ARGV[0]
fh = File.new(fn)
msgpack_unpacker = MessagePack::Unpacker.new(fh)
begin
msgpack_unpacker.each do | tag, id, record|
puts "-- pushing data in tag " ; puts tag ; puts "--- object id"; puts id ; puts "---- message"; puts record ; # just for debug
logger.post(tag, record )
end
ensure
fh.close
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment