Method: Fluent::GroupCounterOutput#generate_fields

Defined in:
lib/fluent/plugin/out_groupcounter.rb

#generate_fields(counts_per_tag, output = {}, key_prefix = '') ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/fluent/plugin/out_groupcounter.rb', line 115

def generate_fields(counts_per_tag, output = {}, key_prefix = '')
  return {} unless counts_per_tag
  # total_count = counts_per_tag.delete('__total_count')

  counts_per_tag.each do |group_key, count|
    group_key_with = group_key.empty? ? "" : group_key + @delimiter
    output[key_prefix + group_key + @count_suffix] = count[:count] if count[:count]
    output[key_prefix + group_key_with + "#{@min_key}#{@min_suffix}"] = count[:min] if count[:min]
    output[key_prefix + group_key_with + "#{@max_key}#{@max_suffix}"] = count[:max] if count[:max]
    output[key_prefix + group_key_with + "#{@avg_key}#{@avg_suffix}"] = count[:sum] / (count[:count] * 1.0) if count[:sum] and count[:count] > 0
    # output[key_prefix + group_key_with + "rate"] = ((count[:count] * 100.0) / (1.00 * step)).floor / 100.0
    # output[key_prefix + group_key_with + "percentage"] = count[:count] * 100.0 / (1.00 * total_count) if total_count > 0
  end

  output
end