class Fluent::Plugin::PrometheusPushgatewayOutput
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_prometheus_pushgateway.rb, line 59 def initialize super @registry = ::Prometheus::Client.registry end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# 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?()
click to toggle source
# File lib/fluent/plugin/out_prometheus_pushgateway.rb, line 65 def multi_workers_ready? true end
process(tag, es)
click to toggle source
# File lib/fluent/plugin/out_prometheus_pushgateway.rb, line 98 def process(tag, es) # nothing end
start()
click to toggle source
Calls superclass method
# 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
Private Instance Methods
tls_options()
click to toggle source
# File lib/fluent/plugin/out_prometheus_pushgateway.rb, line 104 def tls_options opt = {} if @tls_ca_cert_path unless File.file?(@tls_ca_cert_path) raise Fluent::ConfigError, "tls_ca_cert_path is wrong: #{@tls_ca_cert_path}" end opt[:ca_file] = @tls_ca_cert_path end if @tls_client_cert_path unless File.file?(@tls_client_cert_path) raise Fluent::ConfigError, "tls_client_cert_path is wrong: #{@tls_client_cert_path}" end opt[:cert] = OpenSSL::X509::Certificate.new(File.read(@tls_client_cert_path)) end if @tls_private_key_path unless File.file?(@tls_private_key_path) raise Fluent::ConfigError, "tls_private_key_path is wrong: #{@tls_private_key_path}" end opt[:key] = OpenSSL::PKey.read(File.read(@tls_private_key_path), @tls_private_key_passphrase) end opt[:verify_mode] = case @tls_verify_mode when :none OpenSSL::SSL::VERIFY_NONE when :peer OpenSSL::SSL::VERIFY_PEER end opt[:ciphers] = @tls_ciphers opt[:ssl_version] = @tls_version opt end