Sha256: b90c8f63ed3bae2641ec8a62bbbc423bcea5eff63c4f9ff919a627df52a25f8b

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'fluent/plugin/in_http'
require_relative 'logplex'

module Fluent
  class HerokuSyslogHttpInput < HttpInput
    Plugin.register_input('heroku_syslog_http', self)
    include Logplex

    config_param :format, :string, :default => SYSLOG_HTTP_REGEXP
    config_param :drain_ids, :array, :default => nil

    private

    def parse_params_with_parser(params)
      if content = params[EVENT_RECORD_PARAMETER]
        records = []
        messages = content.split("\n")
        messages.each do |msg|
          @parser.parse(msg) { |time, record|
            raise "Received event is not #{@format}: #{content}" if record.nil?

            record["time"] ||= time
            parse_logplex(record, params)
            unless @drain_ids.nil? || @drain_ids.include?(record['drain_id'])
              log.warn "drain_id not match: #{msg.inspect}"
              next
            end
            records << record
          }
        end
        return nil, records
      else
        raise "'#{EVENT_RECORD_PARAMETER}' parameter is required"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-heroku-syslog-0.1.1 lib/fluent/plugin/in_heroku_syslog_http.rb