Skip to content

enlivit/sidekiq-prometheus-exporter

 
 

Repository files navigation

Build Status Maintainability Test Coverage

Sidekiq Prometheus Exporter

— Hey! Sidekiq dashboard stats looks like a Prometheus metrics!?

— Indeed ... 🤔

Grafana dashboard example

Open dashboard example file, then open https://<your grafana-url>/dashboard/import and paste the content of the file.

Available metrics

(starting Sidekiq v3.3.1)

sidekiq_processed_jobs_total   counter  The total number of processed jobs.
sidekiq_failed_jobs_total      counter  The total number of failed jobs.
sidekiq_busy_workers           gauge    The number of workers performing the job.
sidekiq_enqueued_jobs          gauge    The number of enqueued jobs.
sidekiq_scheduled_jobs         gauge    The number of jobs scheduled for a future execution.
sidekiq_retry_jobs             gauge    The number of jobs scheduled for the next try.
sidekiq_dead_jobs              gauge    The number of jobs being dead.
sidekiq_queue_latency_seconds  gauge    The amount of seconds between oldest job being pushed
                                        to the queue and current time (labels: name).
sidekiq_queue_enqueued_jobs    gauge    The number of enqueued jobs in the queue (labels: name).

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-prometheus-exporter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sidekiq-prometheus-exporter -v '~> 0.1'

Rack application

For a fresh new application to expose metrics create config.ru file with next code inside

require 'sidekiq'
require 'sidekiq/prometheus/exporter'

Sidekiq.configure_client do |config|
  config.redis = {url: 'redis://<your-redis-host>:6379/0'}
end

run Sidekiq::Prometheus::Exporter.to_app

use your favorite server to start it up, like this

$ bundle exec rackup -p9292 -o0.0.0.0

and then curl https://0.0.0.0:9292/metrics

Sidekiq Web (extream)

If you are fine, that metrics will be exposed via Sidekiq web dashboard because you have it inside your private network or only Prometheus scraper will have an access to a machine/port/etc, then add a few lines into your web config.ru

require 'sidekiq/web'
require 'sidekiq/prometheus/exporter'

Sidekiq::Web.register(Sidekiq::Prometheus::Exporter)

and then curl https://<your-sidekiq-web-uri>/metrics

Contributing

Bug reports and pull requests to support earlier versions of Sidekiq are welcome on GitHub at https://github.com/Strech/sidekiq-prometheus-exporter/issues.

License

Please see LICENSE for licensing details.

About

All the basic metrics of Sidekiq prepared for Prometheus

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 82.0%
  • HTML 16.8%
  • Shell 1.2%