Class: Fluent::PrometheusInput::MonitorServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/fluent/plugin/in_prometheus.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, prometheus) ⇒ MonitorServlet

Returns a new instance of MonitorServlet.



50
51
52
# File 'lib/fluent/plugin/in_prometheus.rb', line 50

def initialize(server, prometheus)
  @prometheus = prometheus
end

Instance Method Details

#do_GET(req, res) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/fluent/plugin/in_prometheus.rb', line 54

def do_GET(req, res)
  res.status = 200
  res['Content-Type'] = ::Prometheus::Client::Formats::Text::CONTENT_TYPE
  res.body = ::Prometheus::Client::Formats::Text.marshal(@prometheus.registry)
rescue
  res.status = 500
  res['Content-Type'] = 'text/plain'
  res.body = $!.to_s
end