From 96d72ed4d7fdd9cfa429e6b17e0a289f37427723 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 17 Feb 2019 16:59:11 +0000 Subject: Add prometheus endpoint --- scarecrow.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scarecrow.rb b/scarecrow.rb index a527515..71adf45 100644 --- a/scarecrow.rb +++ b/scarecrow.rb @@ -9,6 +9,9 @@ require 'dm-migrations' set :public_folder, File.dirname(__FILE__) + '/public' set :bind, '::' +configure do + mime_type :text, 'text/plain' +end DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/scarecrow.sqlite") class Temperature @@ -86,4 +89,11 @@ get '/humidity' do "#{humidity}" end +get '/metrics' do + content_type :text + humidity = Humidity.last[:value] + temp = Temperature.last[:value] + "humidity #{humidity}\ntemperature #{temp}" +end + init -- cgit v1.2.3