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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With