lxc-exporter/config.ru

18 lines
438 B
Text
Raw Normal View History

2023-10-13 11:28:46 +02:00
require 'rack'
2024-09-03 15:38:09 +02:00
require 'json'
2023-10-13 11:28:46 +02:00
require 'prometheus/client/formats/text'
2024-09-03 15:38:09 +02:00
require_relative 'lib/lxc_collector'
2023-10-13 11:28:46 +02:00
run lambda {|env|
req = Rack::Request.new env
case req.path
2024-01-20 23:22:16 +01:00
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)]]
2024-01-20 23:22:16 +01:00
2023-10-13 11:28:46 +02:00
else
[404, {"Content-Type" => "text/plain"}, ["Not found\nYou want to try /metrics?\n"]]
end
}