Created
December 19, 2014 02:07
-
-
Save kiyoto/e22c3238aced02b2547a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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