Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to show the Sidekiq web dashboard for one application on another?

From the Sidekiq monitor readme, you can protect the sidekiq web dashboard route on your current rails server (say localhost running on port 3000) using:

Typical way to do authenticated sidekiq dashboard route on http://localhost:3000

# config/routes.rb
authenticate :user, lambda { |u| u.admin? } do
  mount Sidekiq::Web => '/sidekiq'
end

I want to use another Rails application to access the Sidekiq dashboard (instead of the Rails application on which Sidekiq is running):

Is it possible to do something like the following:

App 1 - In http://localhost:3000 rails server: (server on which Sidekiq is running and collecting data)

# config/routes.rb
mount Sidekiq::Web => 'http://localhost:5000/sidekiq'

App 2 - In http://localhost:5000 rails server (separate server I want to capture Sidekiq data, and still protect access to who can see the dashboard)

# config/routes.rb
authenticate :user, lambda { |u| u.admin? } do
  get '/sidekiq'
end

I'm thinking it's not based on my understanding of how mounting Rails engines and Sidekiq dashboard works. My other thought is that I could tap into Sidekiq's API if I want to pass data from server on port 3000 (where Sidekiq stats is running and collecting data) to another server.

EDIT:

Is it also possible to monitor more than one Rails app from App 2? (the localhost:5000 server)

like image 679
Nona Avatar asked Jan 21 '16 22:01

Nona


Video Answer


1 Answers

You can retain the mounting in app 2 (presuming you auth in in that app):

# config/routes.rb
authenticate :user, lambda { |u| u.admin? } do
  mount Sidekiq::Web => '/sidekiq'
end

and point the REDIS_URL environment variable at the redis URL of your target app. (This mechanism varies broadly on your runtime environment.) You'll need to also make sure that all firewalls allow this traffic through, etc.

The mounting ensures that the monitoring interface is available in App 2, and pointing it to the Redis instance from App 1 ensures the correct statistics are accessed.

like image 191
Jim Van Fleet Avatar answered Oct 10 '22 08:10

Jim Van Fleet