kai kai - 6 months ago 15
Ruby Question

[promethues, rails]How to enable promethues on rails server

I have a live rails application.

And I trying install prometheus monitoring service
, Ruby Client

I running on server thses tutorial.

It working good!

But after a hours these merics url is died.

How to working on my live server?

if I adding exist project.

below, Promethus not found error

I, [2015-08-31T10:54:40.274066 #3542] INFO -- : Refreshing Gem list
/PATH/shared/bundle/ruby/2.2.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- prometheus/client/rack/collector (LoadError)
from /PATH/shared/bundle/ruby/2.2.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
from /PATH/shared/bundle/ruby/2.2.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
from /PATH/shared/bundle/ruby/2.2.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'
from config.ru:8:in `block in <main>'
from /PATH/shared/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
from /PATH/shared/bundle/ruby/2.2.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `eval'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn.rb:48:in `block in builder'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `call'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:768:in `build_app!'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:632:in `init_worker_process'
from PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:655:in `worker_loop'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:529:in `spawn_missing_workers'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:540:in `maintain_worker_count'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:294:in `join'
from /PATH/shared/bundle/ruby/2.2.0/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'
from /PATH/shared/bundle/ruby/2.2.0/bin/unicorn:23:in `load'
from /PATH/shared/bundle/ruby/2.2.0/bin/unicorn:23:in `<main>'


eg.)

I have two server(promethus_server, live_server + prometheus client)

live_server, promethus_client path is different path.

I runnning promethus_client manually on server

$ rails new client
$ bundle (adding promethus-client Gem)
$ vi config.ru (add promethus lib)
$ rail s --binding=IP


Is it ircorrect?

Dan Dan
Answer

Here's what my config.ru looks like for a recent app I upgraded:

require ::File.expand_path('../config/environment', FILE)
require 'rack'
require 'prometheus/client/rack/collector'
require 'prometheus/client/rack/exporter'

use Prometheus::Client::Rack::Collector
use Prometheus::Client::Rack::Exporter

run Rails.application