Skip to content

Metrics

Mike Perham edited this page Jul 28, 2022 · 22 revisions

Sidekiq 7.0 introduces a subsystem for gathering job execution times along with a new Metrics tab within the Web UI to explore this data. The data is designed to help you answer a few questions:

  • Which type of jobs executed?
  • Which type of jobs took the most amount of time to execute?
  • How has the performance of Job X changed over the last hour?
  • When did any deploys occur during this time?

Metrics Home

The Metrics home page shows two lists:

  1. The top N jobs by execution count
  2. The top N jobs by total execution time

Each job links to a detail page where you can see the data for the last hour for that job.

Metrics Job Detail

The detail page shows fine-grained data per-minute for the given job. Each minute has a histogram of execution times.

Deploys

Sidekiq provides a simple API so capistrano scripts or similar can mark a deploy. The Metrics graphs will show a vertical line at that point in time so sudden changes can be correlated. If the current directory is a Git repo, here's a simple script which will label mark each deploy with the current git SHA and commit subject (e.g. "d0f12ab3 Add foo to bar"):

require "sidekiq/metrics/deploy"
gitdesc = `git log -1 --format="%h %s"`.strip
Sidekiq::Metrics::Deploy.new.mark(label: gitdesc)

Contributing

The Metrics subsystem is brand new and rough right now. It's ripe for improvement! I am especially interested in high-quality graphs and visualizations in the Web UI. Here's how to contribute:

  1. Fork and clone the repo: git clone git@github.com:USERNAME/sidekiq.git
  2. bundle && cd myapp && bundle
  3. SIDEKIQ_METRICS_BETA=1 bin/rails s
  4. SIDEKIQ_METRICS_BETA=1 bundle exec sidekiq
  5. bundle exec rake seed_jobs
  6. Open http://localhost:3000/sidekiq/metrics

Refresh the Metrics page over the next few minutes as jobs are performed and metrics data streams into Redis. The Ruby code is in lib/sidekiq/metrics. The Web UI is in web/views/metrics*.erb. As time passes, you will need to periodically re-seed the data by re-running the rake task.

Clone this wiki locally