Pro Metrics
Last synchronized at 2026-01-12T22:47:32Z
Sidekiq Pro can send runtime metrics to Statsd for distribution. Set up a global metrics handler and add the [[middleware]] to track job execution.
Enabling Metrics
# Add gem 'dogstatsd-ruby' to your Gemfile
require 'datadog/statsd'
# WARNING Be careful here. I've found that when using UDP, Statsd can perform a DNS lookup
# on the hostname for every single packet. This can lead to mysterious but severe
# performance issues.
#
# You might consider installing a local caching DNS resolver instead (e.g. dnsmasq)
# or performing the DNS resolution once, here in the initializer.
Sidekiq.configure_server do |config|
# As of Sidekiq Pro 8.0, this is the recommended Statsd tag/namespace configuration.
# Read more about global tags: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/
config.dogstatsd = ->{
Datadog::Statsd.new("metrics.example.com", 8125,
tags: ["env:#{config[:environment]}", "service:sidekiq"],
namespace: Rails.application.name
)
}
config.server_middleware do |chain|
require 'sidekiq/middleware/server/statsd'
chain.add Sidekiq::Middleware::Server::Statsd
end
end
Importing Statsd
Other metrics systems will have ingesters for importing Statsd metric data into their native format:
Metrics
Sidekiq Pro will send the following metrics for each job:
jobs.count => counter
jobs.success => counter
jobs.failure => counter
jobs.perform => gauge (time)
jobs.perform_dist => distribution (time)
i.e. count will always be incremented. success or failure will be incremented based on the outcome. perform tracks the amount of time (in milliseconds) spent in the worker. Your Statsd system may provide additional metrics based on these explicit ones..
Tags
Sidekiq Pro sends several tags with each metric. Some Statsd platforms will accept these tags and allow you to visualize/report the perform metrics based on these additional dimensions:
tags: ["worker:VideoEncodeWorker", "queue:bulk"]
Dynamic Options
If you want to set per-job options for the metrics, you can customize the options used within the middleware:
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
require 'sidekiq/middleware/server/statsd'
chain.add Sidekiq::Middleware::Server::Statsd
end
Sidekiq::Middleware::Server::Statsd.options = ->(w, j, q) do
{
tags: ["worker:#{w}", "queue:#{q}"],
sample_rate: (j['dd_rate'] || 1.0)
}
end
end
Note how we are using an attribute within the job payload to control the sample_rate option, like so:
class Myapp::HighVolumeJob
include Sidekiq::Job
sidekiq_options dd_rate: 0.1
Slick!
Commercial Metrics
Several other metrics are sent for various Pro features:
jobs.expired - when a job is expired
jobs.recovered.push - when a job is recovered by reliable_push after network outage
jobs.recovered.fetch - when a job is recovered by super_fetch after process crash
jobs.poison - when a poison pill job is detected and killed by super_fetch
batch.created - when a batch is created
batch.complete - when a batch is completed
batch.success - when a batch is successful
batches.duration => gauge (time)
batches.duration_dist => distribution (time)
Historical Data
Sidekiq Pro is limited to metrics which are focused on individual job executions. For global historical data (e.g. charting the numbers you see in the Web UI) please read [[Ent-Historical-Metrics]].
Distributions
All *_dist metrics use the proprietary Datadog distribution datatype, which provide much better histograms for monitoring. You can disable these datatypes if you wish to avoid proprietary extensions:
Sidekiq.configure_server { |c|
c[:use_datadog_extensions] = false
}
Notes
- As of Sidekiq Pro 7.0, the
dogstatsd-rubygem is the only supported Statsd client library.statsd-rubysupport was removed as it was not getting nearly as much maintenance and it does not support features like tagging. - As of Sidekiq Pro 8.0, all metrics are prefixed with
sidekiq.so you do not need to declare asidekiqnamespace anymore.
- API
- Active-Job
- Advanced-Options
- Batches
- Best-Practices
- Build-vs-Buy
- Bulk-Queueing
- Comm-Installation
- Commercial-FAQ
- Commercial-Support
- Commercial-collaboration
- Complex-Job-Workflows-with-Batches
- Delayed-extensions
- Deployment
- Devise
- Embedding
- Ent-Encryption
- Ent-Historical-Metrics
- Ent-Leader-Election
- Ent-Multi-Process
- Ent-Periodic-Jobs
- Ent-Rate-Limiting
- Ent-Rolling-Restarts
- Ent-Unique-Jobs
- Ent-Web-UI
- Error-Handling
- FAQ
- Getting-Started
- Heroku
- Home
- Iteration
- Job-Format
- Job-Lifecycle
- Kubernetes
- Logging
- Memory
- Metrics
- Middleware
- Miscellaneous-Features
- Monitoring
- Pro-API
- Pro-Expiring-Jobs
- Pro-Metrics
- Pro-Reliability-Client
- Pro-Reliability-Server
- Pro-Web-UI
- Problems-and-Troubleshooting
- Profiling
- Really-Complex-Workflows-with-Batches
- Related-Projects
- Reliability
- Scaling
- Scheduled-Jobs
- Sharding
- Signals
- Testimonials
- Testing
- The-Basics
- Using-Dragonfly
- Using-Redis