lxc-exporter/config.ru

15 lines
416 B
Plaintext
Raw Normal View History

2023-10-13 11:28:46 +02:00
require 'rack'
require_relative 'lxc-exporter'
2023-10-13 11:28:46 +02:00
require 'prometheus/client/formats/text'
run lambda {|env|
req = Rack::Request.new env
case req.path
when "/metrics"
collector = LxcCollector.new
2023-10-13 11:28:46 +02:00
[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
}