Class: Fluent::PrometheusInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_prometheus.rb

Defined Under Namespace

Classes: MonitorServlet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrometheusInput

Returns a new instance of PrometheusInput.



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

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

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



13
14
15
# File 'lib/fluent/plugin/in_prometheus.rb', line 13

def registry
  @registry
end

Instance Method Details

#configure(conf) ⇒ Object



20
21
22
# File 'lib/fluent/plugin/in_prometheus.rb', line 20

def configure(conf)
  super
end

#shutdownObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fluent/plugin/in_prometheus.rb', line 37

def shutdown
  super
  if @server
    @server.shutdown
    @server = nil
  end
  if @thread
    @thread.join
    @thread = nil
  end
end

#startObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fluent/plugin/in_prometheus.rb', line 24

def start
  super
  @server = WEBrick::HTTPServer.new(
    BindAddress: @bind,
    Port: @port,
    MaxClients: 5,
    Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
    AccessLog: [],
  )
  @server.mount(@metrics_path, MonitorServlet, self)
  @thread = Thread.new { @server.start }
end