Sha256: fed3f4c0fe6859edcfff680931a1439b712092086a2a62fd7914537ad02434b8

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require_relative 'ec2_metadata'

module Fluent
  class EC2MetadataOutput < Output
    include EC2Metadata

    Fluent::Plugin.register_output('ec2_metadata', self)

    # Define `router` method of v0.12 to support v0.10 or earlier
    unless method_defined?(:router)
      define_method("router") { Fluent::Engine }
    end

    unless method_defined?(:log)
      define_method(:log) { $log }
    end

    config_param :output_tag, :string
    config_param :aws_key_id, :string, :default => ENV['AWS_ACCESS_KEY_ID'], :secret => true
    config_param :aws_sec_key, :string, :default => ENV['AWS_SECRET_ACCESS_KEY'], :secret => true
    config_param :metadata_refresh_seconds, :integer, :default => 300

    attr_reader :ec2_metadata

    def emit(tag, es, chain)
      tag_parts = tag.split('.')
      es.each { |time, record|
        new_tag, new_record = modify(@output_tag, record, tag, tag_parts)
        router.emit(new_tag, time, new_record)
      }
      chain.next
    rescue => e
      log.warn "ec2-metadata: #{e.class} #{e.message} #{e.backtrace.join(', ')}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-ec2-metadata-0.0.15 lib/fluent/plugin/out_ec2_metadata.rb
fluent-plugin-ec2-metadata-0.0.14 lib/fluent/plugin/out_ec2_metadata.rb