class LogStash::Filters::IP2Location
Public Instance Methods
filter(event)
click to toggle source
# File lib/logstash/filters/ip2location.rb, line 46 def filter(event) ip = event.get(@source) return unless filter?(event) if value = Cache.find(event, ip, @ip2locationfilter, @cache_size).get('ip2location') event.set('ip2location', value) filter_matched(event) else tag_iplookup_unsuccessful(event) end end
register()
click to toggle source
# File lib/logstash/filters/ip2location.rb, line 31 def register if @database.nil? @database = ::Dir.glob(::File.join(::File.expand_path("../../../vendor/", ::File.dirname(__FILE__)),"IP2LOCATION-LITE-DB1.IPV6.BIN")).first if @database.nil? || !File.exists?(@database) raise "You must specify 'database => ...' in your ip2location filter (I looked for '#{@database}')" end end @logger.info("Using ip2location database", :path => @database) @ip2locationfilter = org.logstash.filters.IP2LocationFilter.new(@source, @target, @database, @use_memory_mapped) end
tag_iplookup_unsuccessful(event)
click to toggle source
# File lib/logstash/filters/ip2location.rb, line 58 def tag_iplookup_unsuccessful(event) @logger.debug? && @logger.debug("IP #{event.get(@source)} was not found in the database", :event => event) end