Class: Fluent::DowncaseKeyOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::DowncaseKeyOutput
- Defined in:
- lib/fluent/plugin/out_downcase_keys.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #downcase_keys(record) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
- #get_placeholder(match_data) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
8 9 10 11 12 |
# File 'lib/fluent/plugin/out_downcase_keys.rb', line 8 def configure conf super @remove_tag_prefix = /^#{Regexp.escape @remove_tag_prefix}\.?/ if @remove_tag_prefix end |
#downcase_keys(record) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/out_downcase_keys.rb', line 26 def downcase_keys record new_record = {} record.each do |key, value| if @deep_rename if value.is_a? Hash value = downcase_keys value elsif value.is_a? Array value = value.map { |v| v.is_a?(Hash) ? downcase_keys(v) : v } end end new_record[key.downcase] = value end new_record end |
#emit(tag, es, chain) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fluent/plugin/out_downcase_keys.rb', line 14 def emit tag, es, chain es.each do |time, record| new_tag = @remove_tag_prefix ? tag.sub(@remove_tag_prefix, '') : tag new_tag = "#{new_tag}.#{@append_tag}".sub(/^\./, '') new_record = downcase_keys record Fluent::Engine.emit new_tag, time, new_record end chain.next end |
#get_placeholder(match_data) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/fluent/plugin/out_downcase_keys.rb', line 45 def get_placeholder match_data placeholder = {} match_data.to_a.each_with_index do |e, idx| placeholder.store "${md[#{idx}]}", e end placeholder end |