Configure the built-in indicators
The health endpoint runs every indicator listed in health.indicators. Each key is the component
name in the JSON. Each value is a class name, or a class name with constructor arguments:
'name' => IndicatorClass::class,'name' => [IndicatorClass::class, ['argument' => 'value']],The container builds the indicator and passes the arguments by name. The health indicators reference lists the arguments of each built-in indicator.
Remove an indicator
Section titled “Remove an indicator”Delete its line, or comment it out. For example, to stop checking the cache:
'indicators' => [ 'ping' => PingHealthIndicator::class, 'readinessState' => ReadinessStateHealthIndicator::class, 'diskSpace' => DiskSpaceHealthIndicator::class, 'db' => DatabaseHealthIndicator::class, 'cache' => CacheHealthIndicator::class,],If a health group still includes the removed name, the health endpoint throws an exception. Remove the name from the group too.
Check a specific database connection
Section titled “Check a specific database connection”DatabaseHealthIndicator checks the default connection. Pass connection to check another one:
'db' => [DatabaseHealthIndicator::class, ['connection' => 'pgsql']],Check several connections
Section titled “Check several connections”Register the same indicator under several names:
'db' => DatabaseHealthIndicator::class,'reportingDb' => [DatabaseHealthIndicator::class, ['connection' => 'reporting']],'sessionsCache' => [CacheHealthIndicator::class, ['store' => 'redis']],Each name becomes its own component, with its own status.
Change the disk space path or threshold
Section titled “Change the disk space path or threshold”DiskSpaceHealthIndicator checks the disk that holds the application, and reports DOWN below
10 MB of free space. Pass path and threshold (in bytes) to change this:
'diskSpace' => [DiskSpaceHealthIndicator::class, [ 'path' => storage_path(), 'threshold' => 1024 * 1024 * 1024, // 1 GB]],To watch a mounted volume as well, add a second entry:
'uploadsDisk' => [DiskSpaceHealthIndicator::class, ['path' => '/mnt/uploads']],A path that does not exist reports DOWN, with exists: false.
Enable the Redis indicator
Section titled “Enable the Redis indicator”The Redis indicator is off by default, because not every application uses Redis.
-
Install a Redis client: the
phpredisextension, orcomposer require predis/predis. -
Uncomment the indicator, or add it:
config/actuator.php use Nwidart\Actuator\Health\Indicators\RedisHealthIndicator;'redis' => RedisHealthIndicator::class, -
To check a connection other than
default, passconnection:config/actuator.php 'redis' => [RedisHealthIndicator::class, ['connection' => 'cache']],
Check the result
Section titled “Check the result”On your machine, show the details to see every indicator and its status:
ACTUATOR_HEALTH_SHOW_DETAILS=alwayscurl http://localhost/actuator/healthDo not keep always in production. See
show health details to authorized users.