Actions
Feature #42008
closedExpose default Rails health check endpoint "/up" for load balancers and uptime monitoring
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
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 2 months ago
- Target version changed from Candidate for next major release to 6.0.4
Setting the target version to 6.0.4.
Updated by Go MAEDA about 2 months ago
- Subject changed from Expose default rails health check to Expose default Rails health check endpoint "/up" for load balancers and uptime monitoring
Updated by Go MAEDA about 2 months ago
- Status changed from New to Resolved
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch in r23487.
Thank you for your contribution.
Updated by Go MAEDA about 2 months ago
- Status changed from Resolved to Closed
Merged the change into the 6.0-stable branch in r23490.
Updated by Turnip Zoink 10 days 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.
Actions