protor-ruby

Prometheus aggregator client for ruby

Installation

In Gemfile

gem 'protor'

Then run

bundle install

Usage

Counter

It automatically aggregate value

protor.counter(:counter, 1, {label1: 1}) # value => 1
protor.counter(:counter, 1, {label1: 1}) # value => 2

Gauge

It automatically replace value

protor.gauge(:gauge, 50) # value 50
protor.gauge(:gauge, 20) # value 20

Histogram

It save all observed values

protor.histogram(:histogram, 10, {label1: 1}, [1,2,3,4]) # observed value [10]
protor.histogram(:histogram, 2, {label1: 1}, [1,2,3,4](  # observed value [10,2]

Publish

To publish all saved metrics to aggregator

protor.publish

Configuration

To configure protor:

$protor = Protor.new do |conf|
  conf[:service] = 'service name' # required service name 
  conf[:host] = 'localhost' # optional prometheus_aggregator host
  conf[:port] = 8080 # optional prometheus_aggregator port
  conf[:logger] = Rails.logger # optional logger to be used by protor
  conf[:silent] = True #optional, set it to true if you dont want receive raise error
end