Sha256: f6efbf9dfccfe411911919064d83e86e4d3c9eb5a91ceef4a05d7f89ef2581dc

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

require 'fluent/plugin/filter'
require_relative 'ec2_metadata'

module Fluent::Plugin
  class EC2MetadataFilter < Filter
    include Fluent::EC2Metadata

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

    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
    config_param :imdsv2, :bool, default: false

    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

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-ec2-metadata-0.1.3 lib/fluent/plugin/filter_ec2_metadata.rb