Much has been written about using Redis in Rails for various things. We are using it for caching data and running Sidekiq. Sidekiq web UI gives you nice visibility into how Sidekiq is doing but I wanted to have a more in-depth view of what is actually stored in my Redis DB. I came across Redis-Browser and wanted to share some lessons learned.

Create config/initalizers/redis-browser.rb

unless Rails.env.test?
  settings = {"connections"=>{
    "default"=>{"url"=>"redis://#{Rails.application.config.redis_host}:6379/0"},
    "db1"=>{"url"=>"redis://#{Rails.application.config.redis_host}:6379/1"},
  }}
  RedisBrowser.configure(settings)
end

This will allow you to connect to Redis DB0 or DB1 via simple selector. We are storing cache in DB0 and Sidekiq jobs in DB1.

Modify routes.rb.

...
authenticate :user, lambda { |u| u.roles.include? :sysadmin } do
  unless Rails.env.test?
    require 'sidekiq/web'
    mount Sidekiq::Web => '/sidekiq'
    mount RedisBrowser::Web => '/redis'
  end
end
...

This will ensure that only users with role sysadmin will be able to access the route. Much easier than separate HTTP auth username/password. Both Sidekiq Web and Redis-Browser run as Sinatra apps so see their respective docs for install instructions.

You can also put this in your Sidekiq initializer to link to /redis URL.

Sidekiq::Web.app_url = '/redis'