Class: Fluent::Plugin::PrometheusPushgatewayOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_prometheus_pushgateway.rb

Instance Method Summary collapse

Constructor Details

#initializePrometheusPushgatewayOutput

Returns a new instance of PrometheusPushgatewayOutput.



59
60
61
62
63
# File 'lib/fluent/plugin/out_prometheus_pushgateway.rb', line 59

def initialize
  super

  @registry = ::Prometheus::Client.registry
end

Instance Method Details

#configure(conf) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fluent/plugin/out_prometheus_pushgateway.rb', line 69

def configure(conf)
  super

  @push_client = ::Prometheus::Client::Push.new("#{@job_name}:#{fluentd_worker_id}", @instance, @gateway)

  use_tls = gateway && (URI.parse(gateway).scheme == 'https')

  if use_tls
    # prometheus client doesn't have an interface to set the HTTPS options
    http = @push_client.instance_variable_get(:@http)
    if http.nil?
      log.warn("prometheus client ruby's version unmatched. https setting is ignored")
    end

    # https://github.com/ruby/ruby/blob/dec802d8b59900e57e18fa6712caf95f12324aea/lib/net/http.rb#L599-L604
    tls_options.each do |k, v|
      http.__send__("#{k}=", v)
    end
  end
end

#multi_workers_ready?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/fluent/plugin/out_prometheus_pushgateway.rb', line 65

def multi_workers_ready?
  true
end

#process(tag, es) ⇒ Object



98
99
100
# File 'lib/fluent/plugin/out_prometheus_pushgateway.rb', line 98

def process(tag, es)
  # nothing
end

#startObject



90
91
92
93
94
95
96
# File 'lib/fluent/plugin/out_prometheus_pushgateway.rb', line 90

def start
  super

  timer_execute(:out_prometheus_pushgateway, @push_interval) do
    @push_client.add(@registry)
  end
end