Sha256: 193a617194aa6518f23c14ecb7c3438bef7d71e6cc7ed1643138abc66bdf2148
Contents?: true
Size: 979 Bytes
Versions: 7
Compression:
Stored size: 979 Bytes
Contents
# { # "convert": { # "field": "duration", # "type": "integer" # } # } module Anschel class Filter def convert conf, stats, log field = conf.delete :field type = conf.delete :type raise 'Missing required "field" for "convert" filter' if field.nil? raise 'Missing required "type" for "convert" filter' if type.nil? field = field.to_sym type_conversions = { 'integer' => :to_i, 'float' => :to_f, 'string' => :to_s } stats.create 'filter-convert' stats.create 'filter-convert-skipped' log.info event: 'filter-compiled', kind: 'convert', \ field: field, type: type lambda do |event| unless event.has_key? field stats.inc 'filter-convert-skipped' return event end event[field] = event[field].send type_conversions[type] stats.inc 'filter-convert' filtered event, conf end end end end
Version data entries
7 entries across 7 versions & 1 rubygems