Home

Awesome

Prome

Prometheus for rails and optional sidekiq.

get started

In your Gemfile, add this

gem 'prome', github: 'getqujing/prome'

In config/routes.rb, mount the metrics endpoint

require 'prome/web'
mount Prome::Web, at: "/metrics"

And you are good to go.

sidekiq

Sidekiq server side metrics are served by a standalone web server, by default it will listen to 0.0.0.0:9310 when you start the sidekiq server.

The bind address can be configured like this, in config/initializers/prometheus.rb

Prome.configure do |config|
  config.sidekiq_metrics_host = "127.0.0.1"
  config.sidekiq_metrics_port = 3001
end

default metrics

nametypedescription
rails_requests_totalcounternumber of HTTP requests rails processed
rails_request_duration_secondshistogramA histogram of the response latency
rails_view_runtime_secondshistogramview rendering time per request
rails_db_runtime_secondshistogramactiverecord execution time per request
sidekiq_jobs_executed_totalcounternumber of jobs sidekiq executed
sidekiq_jobs_success_totalcounternumber of jobs successfully processed by sidekiq
sidekiq_jobs_failed_totalcounternumber of jobs failed in sidekiq
sidekiq_job_runtime_secondshistogramjob execution time
sidekiq_jobs_enqueued_totalcounternumber of jobs sidekiq enqueued.
sidekiq_jobs_waiting_countgaugenumber of jobs waiting to process in sidekiq.

Note: all sidekiq related metrics are started from the moment using this gem, not equal to Sidekiq::Stats

custom metrics

Register the metric in initializer

Prome.configure do |config|
  Prome.counter(:app_posts_created_total, "A counter of total number of posts created.")
  # Prome also responds to :histogram, :gauge, :summary, just register what you want :)
end

In Post model

class Post < ApplicationRecord
  after_create do
    Prome.get(:app_posts_created_total).increment({})
  end
end