Sha256: b6e4183844e5e8712476fd5ba353af0652691a1add3eae6f5bc66c74a44378cc

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

require 'fluent/plugin/output'
require_relative 'ec2_metadata'

module Fluent::Plugin
  class EC2MetadataOutput < Output
    include Fluent::EC2Metadata

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

    helpers :event_emitter

    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 process(tag, es)
      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)
      }
    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.1.2 lib/fluent/plugin/out_ec2_metadata.rb
fluent-plugin-ec2-metadata-0.1.1 lib/fluent/plugin/out_ec2_metadata.rb
fluent-plugin-ec2-metadata-0.1.0 lib/fluent/plugin/out_ec2_metadata.rb