Created
July 17, 2013 12:20
-
-
Save ephemeralsnow/6020051 to your computer and use it in GitHub Desktop.
fluentd の out_file で出力したファイルを読み込んで in_forward へ投げる
This file contains 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 '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