lib/fluent/plugin/out_flowcounter.rb in fluent-plugin-flowcounter-0.3.0 vs lib/fluent/plugin/out_flowcounter.rb in fluent-plugin-flowcounter-0.3.1
- old
+ new
@@ -17,10 +17,11 @@
config_param :aggregate, :string, :default => 'tag'
config_param :output_style, :string, :default => 'joined'
config_param :tag, :string, :default => 'flowcount'
config_param :input_tag_remove_prefix, :string, :default => nil
config_param :count_keys, :string
+ config_param :delimiter, :string, :default => '_'
include Fluent::Mixin::ConfigPlaceholders
attr_accessor :counts
attr_accessor :last_checked
@@ -96,12 +97,12 @@
def countup(name, counts, bytes)
c = 'count'
b = 'bytes'
if @aggregate == :tag
- c = name + '_count'
- b = name + '_bytes'
+ c = name + delimiter + 'count'
+ b = name + delimiter + 'bytes'
end
@mutex.synchronize {
@counts[c] = (@counts[c] || 0) + counts
@counts[b] = (@counts[b] || 0) + bytes
}
@@ -120,14 +121,14 @@
generate_output(flushed, step)
end
def tagged_flush(step)
flushed,@counts = @counts,count_initialized(@counts.keys)
- names = flushed.keys.select {|x| x.end_with?('_count')}.map {|x| x.chomp('_count')}
+ names = flushed.keys.select {|x| x.end_with?(delimiter + 'count')}.map {|x| x.chomp(delimiter + 'count')}
names.map {|name|
counts = {
- 'count' => flushed[name + '_count'],
- 'bytes' => flushed[name + '_bytes'],
+ 'count' => flushed[name + delimiter + 'count'],
+ 'bytes' => flushed[name + delimiter + 'bytes'],
}
data = generate_output(counts, step)
data['tag'] = name
data
}