Sha256: 6532e279c2b140fc3e6cab422269121546b40ddfb8be3ec321a011a761b38b9d

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

require_relative 'ec2_metadata'

module Fluent
  class EC2MetadataFilter < Filter
    include Fluent::EC2Metadata

    Fluent::Plugin.register_filter('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

    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 filter(tag, time, record)
      tag_parts = tag.split('.')
      modify_record(record, tag, tag_parts)
    rescue => e
      $log.warn "ec2-metadata: #{e.class} #{e.message} #{e.backtrace.join(', ')}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fluent-plugin-ec2-metadata-0.0.13 lib/fluent/plugin/filter_ec2_metadata.rb
fluent-plugin-ec2-metadata-0.0.12 lib/fluent/plugin/filter_ec2_metadata.rb
fluent-plugin-ec2-metadata-0.0.11 lib/fluent/plugin/filter_ec2_metadata.rb