lib/fluent/plugin/out_grassland.rb in fluent-plugin-grassland-0.0.1 vs lib/fluent/plugin/out_grassland.rb in fluent-plugin-grassland-0.0.1.1
- old
+ new
@@ -1,24 +1,24 @@
module Fluent
class GrasslandOutput < Fluent::BufferedOutput
Fluent::Plugin.register_output('grassland', self)
- attr_accessor :apiuri, :stream_name, :access_key_id, :secret_access_key, :region
+ attr_accessor :stream_name, :access_key_id, :secret_access_key, :region
def initialize
super
require 'aws-sdk'
require 'base64'
require 'json'
require 'logger'
require 'net/http'
require 'uri'
- @apiuri = 'https://s3.amazonaws.com/apicre/credential.json'
end
- config_param :key, :string, :default => nil
- config_param :debug, :bool, :default => false
+ config_param :apiuri, :string, :default => 'https://grassland-api.elasticbeanstalk.com/credential'
+ config_param :key, :string, :default => 'nil'
+ config_param :debug, :bool, :default => false
def configure(conf)
super
[:key].each do |name|
@@ -42,11 +42,11 @@
def shutdown
super
end
def setCredential()
- credential = get_json(@apiuri)
+ credential = get_json("#{@apiuri}?key=#{@key}")
@stream_name = credential['streamName']
@access_key_id = credential['accessKeyId']
@secret_access_key = credential['secretAccessKey']
@region = credential['region']
end
@@ -78,14 +78,17 @@
end
end
def format(tag, time, record)
# print(record)
- ['cid', 'dt', 'uid', 'pt', 'd'].each do |key|
+ ['cid', 'dt', 'uid', 'd'].each do |key|
unless record.has_key?(key)
puts "input data error: '#{key}' is required"
return ""
end
+ end
+ unless record.has_key?('pt')
+ record['pt'] = time
end
record['pk'] = record['cid'] + record['dt']
return "#{record.to_json},"
end