Skip to content

Show health details to authorized users

By default the health endpoint shows only the overall status. Two settings reveal more:

  • show_components lists each component with its status.
  • show_details adds each component’s details, such as the database driver or the free disk space. When show_components is null, it follows show_details.

Both accept never, always or when_authorized.

  1. Set show_details to when_authorized. You can use the environment variable:

    .env
    ACTUATOR_HEALTH_SHOW_DETAILS=when_authorized
  2. Define the viewActuator gate in AppServiceProvider::boot():

    app/Providers/AppServiceProvider.php
    use App\Models\User;
    use Illuminate\Support\Facades\Gate;
    Gate::define('viewActuator', fn (User $user) => $user->is_admin);
  3. Add middleware that authenticates the user, without requiring authentication. Probes still get the minimal response:

    config/actuator.php
    'health' => [
    'middleware' => ['web'],
    'show_details' => env('ACTUATOR_HEALTH_SHOW_DETAILS', 'never'),
    // ...
    ],

    With web, a logged-in administrator who opens /actuator/health in the browser sees the details. An anonymous request sees only the status. For token clients, use a guard that reads the token, such as auth:sanctum, but note that it then rejects anonymous probes.

List the components and their statuses for everyone, but keep the details for authorized users:

config/actuator.php
'show_details' => 'when_authorized',
'show_components' => 'always',
{
"status": "UP",
"components": {
"ping": { "status": "UP" },
"db": { "status": "UP" }
},
"groups": ["liveness", "readiness"]
}
config/actuator.php
'show_details' => env('APP_ENV') === 'production' ? 'when_authorized' : 'always',