lib/fluent/plugin/out_dd.rb in fluent-plugin-dd-0.1.5 vs lib/fluent/plugin/out_dd.rb in fluent-plugin-dd-0.1.6
- old
+ new
@@ -4,11 +4,15 @@
unless method_defined?(:log)
define_method('log') { $log }
end
config_param :dd_api_key, :string
+ config_param :dd_app_key, :string, :default => nil
config_param :host, :string, :default => nil
+ config_param :device, :string, :default => nil
+ config_param :silent, :bool, :default => true
+ config_param :timeout, :integer, :default => nil
config_param :use_fluentd_tag_for_datadog_tag, :bool, :default => false
config_param :emit_in_background, :bool, :default => false
config_param :concurrency, :integer, :default => nil
def initialize
@@ -63,11 +67,11 @@
unless @host
@host = %x[hostname -f 2> /dev/null].strip
@host = Socket.gethostname if @host.empty?
end
- @dog = Dogapi::Client.new(@dd_api_key, nil, @host)
+ @dog = Dogapi::Client.new(@dd_api_key, @dd_app_key, @host, @device, @silent, @timeout)
end
def format(tag, time, record)
[tag, time, record].to_msgpack
end
@@ -104,13 +108,13 @@
if not dd_tag and @use_fluentd_tag_for_datadog_tag
dd_tag = tag
end
- [dd_tag] + record.values_at('metric', 'host', 'type')
+ [dd_tag] + record.values_at('metric', 'host', 'type', 'device')
}.map {|i, records|
- tag, metric, host, type = i
+ tag, metric, host, type, device = i
points = records.map do |tag, time, record|
time = Time.at(time)
value = record['value']
[time, value]
@@ -118,9 +122,10 @@
options = {}
options[:tags] = tag.split(',').map {|i| i.strip } if tag
options[:host] = host if host
options[:type] = type if type
+ options[:device] = device if device
[metric, points, options]
}
end
end