Class: Fluent::GeoipFilter

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



21
22
23
24
# File 'lib/fluent/plugin/filter_geoip.rb', line 21

def configure(conf)
  super
  @geoip = Fluent::GeoIP.new(self, conf)
end

#filter_stream(tag, es) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fluent/plugin/filter_geoip.rb', line 26

def filter_stream(tag, es)
  new_es = MultiEventStream.new
  es.each do |time, record|
    begin
      filtered_record = @geoip.add_geoip_field(record)
      new_es.add(time, filtered_record) if filtered_record
    rescue => e
      router.emit_error_event(tag, time, record, e)
    end
  end
  new_es
end