Skip to content

Instantly share code, notes, and snippets.

@ephemeralsnow
Created July 17, 2013 12:20
Show Gist options
  • Save ephemeralsnow/6020051 to your computer and use it in GitHub Desktop.
Save ephemeralsnow/6020051 to your computer and use it in GitHub Desktop.
fluentd の out_file で出力したファイルを読み込んで in_forward へ投げる
require 'date'
require 'time'
require 'json'
require 'fluent-logger'
logger = Fluent::Logger::FluentLogger.new(nil, :host => '127.0.0.1', :port => 24224)
IO.foreach("fluentd_out_file.log") { |line|
line.scan(/^([^\t]+)\t([^\t]+)\t(.+)$/) { |a|
datetime = DateTime.parse(a[0])
time = datetime.to_time
#time = Time.iso8601(a[0])
tag = a[1]
json = JSON.parse(a[2])
logger.post_with_time(tag, json, time)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment