lxc-exporter/config.ru
2024-09-03 15:38:09 +02:00

18 lines
438 B
Ruby

require 'rack'
require 'json'
require 'prometheus/client/formats/text'
require_relative 'lib/lxc_collector'
run lambda {|env|
req = Rack::Request.new env
case req.path
when '/metrics'
collector = LxcCollector.new
[200, {"Content-Type" => "text/plain"}, [Prometheus::Client::Formats::Text.marshal( collector.collect)]]
else
[404, {"Content-Type" => "text/plain"}, ["Not found\nYou want to try /metrics?\n"]]
end
}