Class: Fluent::Plugin::K8sFilter

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



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

def configure(conf)
  super
  @tag_compiled = Regexp.compile(@tag_regexp)
end

#filter(tag, time, record) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/fluent/plugin/filter_k8s.rb', line 14

def filter(tag, time, record)
  tag_match_data = tag.match(@tag_compiled)
  if !!tag_match_data
    record['namespace_name']=tag_match_data['namespace']
    record['pod_name']=tag_match_data['pod_name']
    record['container_name']=tag_match_data['container_name']
  end
  record
end