Class: Fluent::KubernetesOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::KubernetesOutput
- Defined in:
- lib/fluent/plugin/out_kubernetes.rb
Constant Summary collapse
- K8S_CONTAINER_NAME_REGEX =
'^[^_]+_([^\.]+)\.[^_]+_([^\.]+)\.([^\.]+)'
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
- #enrich_record(record) ⇒ Object
-
#initialize ⇒ KubernetesOutput
constructor
A new instance of KubernetesOutput.
Constructor Details
#initialize ⇒ KubernetesOutput
Returns a new instance of KubernetesOutput.
8 9 10 |
# File 'lib/fluent/plugin/out_kubernetes.rb', line 8 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
12 13 14 |
# File 'lib/fluent/plugin/out_kubernetes.rb', line 12 def configure(conf) super end |
#emit(tag, es, chain) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/fluent/plugin/out_kubernetes.rb', line 16 def emit(tag, es, chain) es.each do |time,record| Fluent::Engine.emit('kubernetes', time, enrich_record(record)) end chain.next end |
#enrich_record(record) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fluent/plugin/out_kubernetes.rb', line 24 def enrich_record(record) if record.has_key? "container_name" regex = Regexp.new(K8S_CONTAINER_NAME_REGEX) match = record["container_name"].match(regex) if match pod_container_name, pod_name, pod_namespace = match.captures record["pod_namespace"] = pod_namespace record["pod"] = pod_name record["pod_container"] = pod_container_name end end record end |