Class: Fluent::PrometheusInput
- Inherits:
-
Input
- Object
- Input
- Fluent::PrometheusInput
- Defined in:
- lib/fluent/plugin/in_prometheus.rb
Defined Under Namespace
Classes: MonitorServlet
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ PrometheusInput
constructor
A new instance of PrometheusInput.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ PrometheusInput
Returns a new instance of PrometheusInput.
32 33 34 35 |
# File 'lib/fluent/plugin/in_prometheus.rb', line 32 def initialize super @registry = ::Prometheus::Client.registry end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
30 31 32 |
# File 'lib/fluent/plugin/in_prometheus.rb', line 30 def registry @registry end |
Instance Method Details
#configure(conf) ⇒ Object
37 38 39 |
# File 'lib/fluent/plugin/in_prometheus.rb', line 37 def configure(conf) super end |
#shutdown ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fluent/plugin/in_prometheus.rb', line 80 def shutdown super if @server @server.shutdown @server = nil end if @thread @thread.join @thread = nil end end |
#start ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fluent/plugin/in_prometheus.rb', line 41 def start super config = { BindAddress: @bind, Port: @port, MaxClients: 5, Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL), AccessLog: [], } unless @ssl.nil? || !@ssl['enable'] require 'webrick/https' require 'openssl' if (@ssl['certificate_path'] && @ssl['private_key_path'].nil?) || (@ssl['certificate_path'].nil? && @ssl['private_key_path']) raise RuntimeError.new("certificate_path and private_key_path most both be defined") end ssl_config = { SSLEnable: true } if @ssl['certificate_path'] cert = OpenSSL::X509::Certificate.new(File.read(@ssl['certificate_path'])) ssl_config[:SSLCertificate] = cert end if @ssl['private_key_path'] key = OpenSSL::PKey::RSA.new(File.read(@ssl['private_key_path'])) ssl_config[:SSLPrivateKey] = key end ssl_config[:SSLCACertificateFile] = @ssl['ca_path'] if @ssl['ca_path'] ssl_config = ssl_config.merge(@ssl['extra_conf']) config = ssl_config.merge(config) end @log.on_debug do @log.debug("WEBrick conf: #{config}") end @server = WEBrick::HTTPServer.new(config) @server.mount(@metrics_path, MonitorServlet, self) @thread = Thread.new { @server.start } end |