class LogStash::Filters::Ezproxy

This filter will replace the contents of the default message field with whatever you specify in the configuration.

It is only intended to be used as an .

Public Instance Methods

filter(event) click to toggle source
# File lib/logstash/filters/ezproxy.rb, line 82
def filter(event)
  begin
    input = URI::extract(event.get(@url))[0]
  rescue => e
    puts e.message
    puts "at"
    puts e.backtrace.inspect
    puts "for"
    puts @url
    event.tag("ezproxy_parse_failure")
  end

  data = {}

  parsed_url = URLParser::parse(input)
  uri = parsed_url['uri']
  path = parsed_url['path']
  params = parsed_url['params']

  unless uri == nil

    begin
      if @mime_tag
        data.merge!(Mime::parse(path))
      end
      if @doc_id_tag
        data.merge!(ParamHelper::parse(params))
      end

      @@hosts.each do |key, value|
        if uri.host.include?(key)
          data.merge!(value.call(path, params, uri))
        end
      end

      event.tag("ezproxy_parse_success")
    rescue => e
      puts e.message
      puts "at"
      puts e.backtrace.inspect
      puts "for"
      puts uri
      event.tag("ezproxy_parse_failure")
    end
    if @path_tag
      data['path'] = path
    end
    event.set(@target, data)
  else
    event.tag("ezproxy_parse_failure")
  end


  # filter_matched should go in the last line of our successful code
  filter_matched(event)
end
register() click to toggle source
# File lib/logstash/filters/ezproxy.rb, line 77
def register
  # Add instance variables
end