Feature #42008
closedExpose default Rails health check endpoint "/up" for load balancers and uptime monitoring
0%
Description
There is a default health check controller available since rails 7.1 (PR).
Newly generated rails apps automatically expose this at the /up route (routes.rb.tt). Add this to redmine routes.rb as well.
Exposing a dedicated health check route makes deployments in containers and behind load balancers more robust and simplifies service monitoring.
Files
Updated by Go MAEDA about 1 year ago
- Category set to Administration
- Target version set to Candidate for next major release
Updated by Turnip Zoink 10 months ago
Lorenz Breu is there some way to silence the logs?
Every 10 seconds its 3 extra lines
│ I, [2025-03-19T22:19:49.434437 #1] INFO -- : [29b001e9-fc72-4550-bdd2-748e155de0ea] Started HEAD "/up" for 127.0.0.1 at 2025-03-19 22:19:49 +0000 │ │ I, [2025-03-19T22:19:49.435432 #1] INFO -- : [29b001e9-fc72-4550-bdd2-748e155de0ea] Processing by Rails::HealthController#show as */* │ │ I, [2025-03-19T22:19:49.436235 #1] INFO -- : [29b001e9-fc72-4550-bdd2-748e155de0ea] Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms) │ │ I, [2025-03-19T22:19:59.509741 #1] INFO -- : [20473365-09e2-4e80-9074-03c525c8f6ce] Started HEAD "/up" for 127.0.0.1 at 2025-03-19 22:19:59 +0000 │ │ I, [2025-03-19T22:19:59.510972 #1] INFO -- : [20473365-09e2-4e80-9074-03c525c8f6ce] Processing by Rails::HealthController#show as */* │ │ I, [2025-03-19T22:19:59.512125 #1] INFO -- : [20473365-09e2-4e80-9074-03c525c8f6ce] Completed 200 OK in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms) │ │ I, [2025-03-19T22:20:09.589080 #1] INFO -- : [6470de22-e067-4b72-96ba-f6c7bacc9fd0] Started HEAD "/up" for 127.0.0.1 at 2025-03-19 22:20:09 +0000 │ │ I, [2025-03-19T22:20:09.590081 #1] INFO -- : [6470de22-e067-4b72-96ba-f6c7bacc9fd0] Processing by Rails::HealthController#show as */* │ │ I, [2025-03-19T22:20:09.590881 #1] INFO -- : [6470de22-e067-4b72-96ba-f6c7bacc9fd0] Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms) │ │ I, [2025-03-19T22:20:19.665771 #1] INFO -- : [2b8759ba-54fa-4bea-96c1-6fbe7b29b1c7] Started HEAD "/up" for 127.0.0.1 at 2025-03-19 22:20:19 +0000 │ │ I, [2025-03-19T22:20:19.667103 #1] INFO -- : [2b8759ba-54fa-4bea-96c1-6fbe7b29b1c7] Processing by Rails::HealthController#show as */* │ │ I, [2025-03-19T22:20:19.668246 #1] INFO -- : [2b8759ba-54fa-4bea-96c1-6fbe7b29b1c7] Completed 200 OK in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms) │ │ I, [2025-03-19T22:20:29.746049 #1] INFO -- : [8c019b39-2d7a-4efc-885d-9ebe952c2c83] Started HEAD "/up" for 127.0.0.1 at 2025-03-19 22:20:29 +0000 │ │ I, [2025-03-19T22:20:29.746955 #1] INFO -- : [8c019b39-2d7a-4efc-885d-9ebe952c2c83] Processing by Rails::HealthController#show as */* │ │ I, [2025-03-19T22:20:29.747738 #1] INFO -- : [8c019b39-2d7a-4efc-885d-9ebe952c2c83] Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms) │ │ I, [2025-03-19T22:20:39.823671 #1] INFO -- : [d2579f09-c949-4956-9cbc-cb50f40c3065] Started HEAD "/up" for 127.0.0.1 at 2025-03-19 22:20:39 +0000 │ │ I, [2025-03-19T22:20:39.824705 #1] INFO -- : [d2579f09-c949-4956-9cbc-cb50f40c3065] Processing by Rails::HealthController#show as */* │ │ I, [2025-03-19T22:20:39.825525 #1] INFO -- : [d2579f09-c949-4956-9cbc-cb50f40c3065] Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
I tried mounting
# app/controllers/rails/health_controller.rb
module Rails
class HealthController < ActionController::Base
def show
puts "Custom HealthController is being used!" # Debug statement
head :ok
end
# Silence logging for this action
def log_process_action(payload)
# Do nothing to prevent logging
end
end
end
and although I see the debug statement in the logs, the logs still show.
Then I tried disabling all logs
# app/controllers/rails/health_controller.rb
module Rails
class HealthController < ActionController::Base
def show
# Silence all logs for this action
Rails.logger.silence do
head :ok
end
end
end
end
but the logs still show.
Updated by Adam Heath about 1 month ago
The logging happens outside the show method, so I'm not surprised that doesn't work. It definitely would be nice to have them turned off, I agree with the request. At least maybe change the level to TRACE or some such.
Updated by Holger Just about 1 month ago
Rails 8 (which will be used with the upcoming Redmine 7.0) introduces a config.silence_healthcheck configuration option.
In older versions, a similar result could likely be achieve by setting a suitable log_at level for the HealthController, e.g log_at :error.
In any case though, this issue is closed. To discuss further improvements, you may open a new issue.