Class: LogStash::Filters::IP2Proxy
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::IP2Proxy
- Defined in:
- lib/logstash/filters/ip2proxy.rb
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/logstash/filters/ip2proxy.rb', line 40 def filter(event) ip = event.get(@source) return unless filter?(event) if value = Cache.find(event, ip, @ip2proxyfilter, @cache_size).get('ip2proxy') event.set('ip2proxy', value) filter_matched(event) else tag_iplookup_unsuccessful(event) end end |
#register ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/logstash/filters/ip2proxy.rb', line 25 def register if @database.nil? @database = ::Dir.glob(::File.join(::File.("../../../vendor/", ::File.dirname(__FILE__)),"IP2PROXY-LITE-PX1.BIN")).first if @database.nil? || !File.exists?(@database) raise "You must specify 'database => ...' in your ip2proxy filter (I looked for '#{@database}')" end end @logger.info("Using ip2proxy database", :path => @database) @ip2proxyfilter = org.logstash.filters.IP2ProxyFilter.new(@source, @target, @database) end |
#tag_iplookup_unsuccessful(event) ⇒ Object
52 53 54 |
# File 'lib/logstash/filters/ip2proxy.rb', line 52 def tag_iplookup_unsuccessful(event) @logger.debug? && @logger.debug("IP #{event.get(@source)} was not found in the database", :event => event) end |