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

21,777

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.

Share:
21,777
Nona
Author by

Nona

Updated on July 31, 2020

Comments

  • Nona
    Nona almost 4 years

    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)

  • Nona
    Nona over 8 years
    Would I need multiple REDIS_URL variables then if I want App 1 to monitor other apps besides App 2? How would Sidekiq web know which one to monitor?
  • Jim Van Fleet
    Jim Van Fleet over 8 years
    @Nona Tricky! Monitoring multiple sidekiqs in one process might not be possible (I haven't looked), but on one box/VM/server would be. It's probably worthy of a separate question.
  • Nona
    Nona over 8 years
    just to double check, github.com/mperham/sidekiq/issues/1223 means that I would have to create one "monitoring app" (like app 2) per each app that I wanted to monitor?
  • Jim Van Fleet
    Jim Van Fleet over 8 years
    @Nona Your interpretation is correct. It should be possible to co-locate the monitoring apps on a single machine though, Sidekiq::Web is not resource intensive.
  • Nona
    Nona over 8 years
    Thanks Jim, thought you might be interested to know Sidekiq PRO does allow you to mount multiple Sidekiq web instances - github.com/mperham/sidekiq/wiki/Pro-Web-UI#sharding
  • Nona
    Nona over 8 years
    I assume that stackoverflow.com/questions/22751402/… means that monitoring Sidekiq via Sidekiq Pro Web by pointing at REDIS URLs means the data "connection" is secure since I'm basically on the Heroku platform the whole time?
  • Jim Van Fleet
    Jim Van Fleet over 8 years
    @Nona SSL certificates are always a good idea, but irrelevant for the question you're asking here. (Traffic to Redis travels through another connection, potentially unencrypted.) If you've provisioned Heroku Redis for your environment, your security is in the hands of Heroku. My impression is that's a good thing, but I'm not in position to comment in depth.