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 }