Class: Fluent::Plugin::RecordSortFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_record_sort.rb

Overview

Filter to sort records and remove fields with no value

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



11
12
13
# File 'lib/fluent/plugin/filter_record_sort.rb', line 11

def configure(conf)
  super
end

#filter(_tag, _time, record) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fluent/plugin/filter_record_sort.rb', line 15

def filter(_tag, _time, record)
  # Remove empty fields
  begin
    record.reject! do |_k, v|
      v.nil? || (v.respond_to?(:empty?) && v.empty?)
    end
  rescue NoMethodError
    log.warn('record_sort plugin has rescued NoMethodError, meaning it'\
              ' let an object pass through without empty field filtering')
  end

  record.sort.to_h
end