Sha256: f2690f803e541625430db892991d4ab64ecab3e08568f501360ffa10d8aab984

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

require 'fluent/plugin/filter'
require 'json'

module Fluent
  class ProcessSnmptrap < Filter
    Fluent::Plugin.register_filter('process_snmptrap', self)

    # config_param
    config_param :coloregion, :string
    # A set of character subsitution for cases in which they are invalid on the collector side.
    config_param :invalidChars, :hash, default: {'.'=>'_'}

    def configure(conf)
      super
    end

    def start
      super
    end

    def filter(tag, time, record)

      # Replace invalid characters
      fixedRecord = Hash.new
      record.each { |recKey, recValue|
          newKey = recKey
          invalidChars.each { |invalidKey, subChar|
              newKey = newKey.gsub(invalidKey, subChar)
          }
          record.delete(recKey)
          fixedRecord[newKey] = recValue
      }
      record.replace(fixedRecord)

      return record
    end


  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-process-snmptrap-0.2.0 lib/fluent/plugin/filter_process_snmptrap.rb
fluent-plugin-process-snmptrap-0.1.0 lib/fluent/plugin/filter_process_snmptrap.rb