2023-10-13 11:28:46 +02:00
|
|
|
require 'rack'
|
2023-10-13 22:50:09 +02:00
|
|
|
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"
|
2023-10-13 22:50:09 +02:00
|
|
|
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
|
|
|
|
}
|