class Fluent::Plugin::ProtocolsFilter
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_protocols.rb, line 14 def configure(conf) super @remove_prefix = Regexp.new("^#{Regexp.escape(remove_prefix)}\.?") unless conf['remove_prefix'].nil? @key_prefix = @key_port + "_" + @key_prefix end
filter_stream(tag, es)
click to toggle source
# File lib/fluent/plugin/filter_protocols.rb, line 20 def filter_stream(tag, es) new_es = Fluent::MultiEventStream.new tag = tag.sub(@remove_prefix, '') if @remove_prefix tag = (@add_prefix + '.' + tag) if @add_prefix es.each do |time, record| unless record[@key_port].nil? record[@key_prefix] = getprotocolname(record[@key_port], record[@key_proto]) rescue nil end new_es.add(time, record) end return new_es end
getprotocolname(port, protocol)
click to toggle source
# File lib/fluent/plugin/filter_protocols.rb, line 34 def getprotocolname(port, protocol) CSV.open(@database_path,"r") do |csv| csv.each do |row| if row[1] == port if row[2] == protocol.downcase return row[0] end end end end end