Module: Fluent::Plugin::PrometheusLabelParser

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fluent/plugin/prometheus.rb', line 8

def configure(conf)
  super
  # Check if running with multiple workers
  sysconf = if self.respond_to?(:owner) && owner.respond_to?(:system_config)
    owner.system_config
  elsif self.respond_to?(:system_config)
    self.system_config
  else
    nil
  end
  @multi_worker = sysconf && sysconf.workers ? (sysconf.workers > 1) : false
end

#parse_labels_elements(conf) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/prometheus.rb', line 21

def parse_labels_elements(conf)
  base_labels = Fluent::Plugin::Prometheus.parse_labels_elements(conf)

  if @multi_worker
    base_labels[:worker_id] = fluentd_worker_id.to_s
  end

  base_labels
end