Class: Fluent::Plugin::NaisLogtransformFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_nais_logtransform.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



9
10
11
# File 'lib/fluent/plugin/filter_nais_logtransform.rb', line 9

def configure(conf)
  super
end

#filter(tag, time, record) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/filter_nais_logtransform.rb', line 13

def filter(tag, time, record)
  if record['kubernetes'].is_a?(Hash) && record['kubernetes']['annotations'].is_a?(Hash)
    transformers = record['kubernetes']['annotations']['nais_io/logtransform']
    unless transformers.nil?
      transformers.split(/ *, */).each { |t|
        if t == 'dns_loglevel'
          level = ::Nais::Log::Parser.loglevel_from_dns_response(record['response_code'])
          record['level'] = level unless level.nil?
        elsif t == 'http_loglevel'
          level = ::Nais::Log::Parser.loglevel_from_http_response(record['response_code'])
          record['level'] = level unless level.nil?
        end
      }
    end
  end
  record
end