Class: Fluent::Plugin::PrometheusFilter

Inherits:
Filter
  • Object
show all
Includes:
Prometheus, PrometheusLabelParser
Defined in:
lib/fluent/plugin/filter_prometheus.rb

Instance Method Summary collapse

Methods included from Prometheus

#instrument, #instrument_single, parse_labels_elements, parse_metrics_elements, placeholder_expander, #stringify_keys

Methods included from PrometheusLabelParser

#parse_labels_elements

Constructor Details

#initializePrometheusFilter

Returns a new instance of PrometheusFilter.



10
11
12
13
# File 'lib/fluent/plugin/filter_prometheus.rb', line 10

def initialize
  super
  @registry = ::Prometheus::Client.registry
end

Instance Method Details

#configure(conf) ⇒ Object



19
20
21
22
23
# File 'lib/fluent/plugin/filter_prometheus.rb', line 19

def configure(conf)
  super
  labels = parse_labels_elements(conf)
  @metrics = Fluent::Plugin::Prometheus.parse_metrics_elements(conf, @registry, labels)
end

#filter(tag, time, record) ⇒ Object



25
26
27
28
# File 'lib/fluent/plugin/filter_prometheus.rb', line 25

def filter(tag, time, record)
  instrument_single(tag, time, record, @metrics)
  record
end

#multi_workers_ready?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/fluent/plugin/filter_prometheus.rb', line 15

def multi_workers_ready?
  true
end