Class: Fluent::Plugin::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.



99
100
101
# File 'lib/fluent/plugin/in_prometheus.rb', line 99

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

Instance Method Details

#do_GET(req, res) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/fluent/plugin/in_prometheus.rb', line 103

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