puma: add Prometheus metrics exporter.
To test it, run `bin/rails server` then do `curl http://localhost:9393`. https://github.com/harmjanblok/puma-metrics
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -53,6 +53,7 @@ gem 'bcrypt_pbkdf' # https://github.com/net-ssh/net-ssh/issues/565
|
|||||||
gem 'terminal-table'
|
gem 'terminal-table'
|
||||||
gem 'newrelic_rpm', require: false
|
gem 'newrelic_rpm', require: false
|
||||||
gem 'clockwork'
|
gem 'clockwork'
|
||||||
|
gem 'puma-metrics'
|
||||||
|
|
||||||
group :production, :staging do
|
group :production, :staging do
|
||||||
gem 'unicorn', :platforms => :ruby
|
gem 'unicorn', :platforms => :ruby
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ GEM
|
|||||||
parser (3.0.2.0)
|
parser (3.0.2.0)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
pg (1.2.3)
|
pg (1.2.3)
|
||||||
|
prometheus-client (2.1.0)
|
||||||
pry (0.13.1)
|
pry (0.13.1)
|
||||||
coderay (~> 1.1)
|
coderay (~> 1.1)
|
||||||
method_source (~> 1.0)
|
method_source (~> 1.0)
|
||||||
@@ -327,6 +328,9 @@ GEM
|
|||||||
public_suffix (4.0.6)
|
public_suffix (4.0.6)
|
||||||
puma (5.4.0)
|
puma (5.4.0)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
|
puma-metrics (1.2.3)
|
||||||
|
prometheus-client (>= 0.10)
|
||||||
|
puma (>= 3.0)
|
||||||
pundit (2.1.1)
|
pundit (2.1.1)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
racc (1.5.2)
|
racc (1.5.2)
|
||||||
@@ -557,6 +561,7 @@ DEPENDENCIES
|
|||||||
pry-byebug
|
pry-byebug
|
||||||
pry-rails
|
pry-rails
|
||||||
puma
|
puma
|
||||||
|
puma-metrics
|
||||||
pundit
|
pundit
|
||||||
rack-mini-profiler
|
rack-mini-profiler
|
||||||
rails (~> 6.0)
|
rails (~> 6.0)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
# * PUMA_WORKER_TIMEOUT
|
# * PUMA_WORKER_TIMEOUT
|
||||||
# * PUMA_PIDFILE
|
# * PUMA_PIDFILE
|
||||||
# * PUMA_CONTROL_URL
|
# * PUMA_CONTROL_URL
|
||||||
|
# * PUMA_METRICS_URL
|
||||||
#
|
#
|
||||||
# Use `bin/pumactl` to control a running Puma instance.
|
# Use `bin/pumactl` to control a running Puma instance.
|
||||||
#
|
#
|
||||||
@@ -84,6 +85,13 @@ end
|
|||||||
# Allow puma to be restarted by `rails restart` command.
|
# Allow puma to be restarted by `rails restart` command.
|
||||||
plugin :tmp_restart
|
plugin :tmp_restart
|
||||||
|
|
||||||
|
# Enable Prometheus metrics.
|
||||||
|
# https://github.com/harmjanblok/puma-metrics
|
||||||
|
plugin :metrics
|
||||||
|
|
||||||
|
# Export Prometheus metrics by default on http://localhost:9393
|
||||||
|
metrics_url ENV.fetch("PUMA_METRICS_URL", "tcp://localhost:9393")
|
||||||
|
|
||||||
# Start the Puma control rack application on +url+. This application can
|
# Start the Puma control rack application on +url+. This application can
|
||||||
# be communicated with to control the main server. Additionally, you can
|
# be communicated with to control the main server. Additionally, you can
|
||||||
# provide an authentication token, so all requests to the control server
|
# provide an authentication token, so all requests to the control server
|
||||||
|
|||||||
Reference in New Issue
Block a user