From 60406d851654db2d9d4f5522458c60fe372e1546 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 26 Feb 2024 10:04:46 +0100 Subject: [PATCH] feat: add puma metrics gem This allows to monitor PUMA via prometheus, providing insights for health, scaling, etc. --- Gemfile | 1 + Gemfile.lock | 5 +++++ config/puma.rb | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/Gemfile b/Gemfile index c7e57429a6..193d8af50c 100644 --- a/Gemfile +++ b/Gemfile @@ -63,5 +63,6 @@ end group :production do gem 'lograge', '~> 0.14.0' + gem 'puma-metrics', '~> 1.2.0' gem 'remote_syslog_logger' end diff --git a/Gemfile.lock b/Gemfile.lock index 36791204bb..29e26f64ae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -312,11 +312,15 @@ GEM ast (~> 2.4.1) racc pg (1.4.5) + prometheus-client (4.2.2) psych (5.1.2) stringio public_suffix (5.0.3) puma (5.6.8) nio4r (~> 2.0) + puma-metrics (1.2.5) + prometheus-client (>= 0.10) + puma (>= 5.0) racc (1.7.3) rack (2.2.8.1) rack-oauth2 (2.2.0) @@ -534,6 +538,7 @@ DEPENDENCIES pagy (~> 6.0, >= 6.0.0) pg puma (~> 5.6) + puma-metrics (~> 1.2.0) rails (~> 7.1.3) redis (~> 4.0) remote_syslog_logger diff --git a/config/puma.rb b/config/puma.rb index f17f921d29..cc594aa541 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -59,3 +59,10 @@ # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart +# Enable puma-metrics gem https://rubygems.org/gems/puma-metrics +plugin 'metrics' +# Bind the metric server to "url". "tcp://" is the only accepted protocol. +# +# The default is "tcp://0.0.0.0:9393", we bind it to localhost to be safe +# by default. +metrics_url 'tcp://127.0.0.1:9393'