Sha256: c2fc30184248c6c2ba5c7ae49c01253850a0bb6eaebd77a17ccc9e481571d65a

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

module Fluent
  class ValidateTagFilter < Filter
    Plugin.register_filter('validate_tag', self)

    config_param :max_length, :integer, default: nil

    def configure(conf)
      super

      @regexps = []
      conf.keys.each do |key|
        if key =~ /\Aregexp[0-9]+\z/
          @regexps << Regexp.new(conf[key])
        end
      end
    end

    def filter(tag, time, record)
      case
      when @max_length && tag.size > @max_length
        nil
      when !@regexps.empty? && @regexps.any? {|regexp| regexp !~ tag }
        nil
      else
        record
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-validate-tag-filter-0.2.1 lib/fluent/plugin/filter_validate_tag.rb