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.



119
120
121
# File 'lib/fluent/plugin/in_prometheus.rb', line 119

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

Instance Method Details

#do_GET(req, res) ⇒ Object



123
124
125
126
127
128
129
130
131
# File 'lib/fluent/plugin/in_prometheus.rb', line 123

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