Prometheus aggregator client for ruby
In Gemfile
gem 'protor'
Then run
bundle install
It automatically aggregate value
protor.counter(:counter, 1, {label1: 1}) # value => 1
protor.counter(:counter, 1, {label1: 1}) # value => 2
It automatically replace value
protor.gauge(:gauge, 50) # value 50
protor.gauge(:gauge, 20) # value 20
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]
To publish all saved metrics to aggregator
protor.publish
To configure protor:
$protor = Protor.new do |conf|
conf[:client] = :udp # valid option :udp and :logger, use :logger to print into a Logger
conf[:host] = 'localhost' # prometheus_aggregator host
conf[:port] = 10601 # prometheus_aggregator port
conf[:logger] = Rails.logger # logger to be used by protor
conf[:packet_size] = 56_607 # max udp packet buffer
conf[:formatter] = :udp # valid option only :udp, format to send
end
Fork the project and send pull requests.