A lightweight, extendable Laravel package for monitoring the health of internal services like Database, Redis, Queue, Cache, Filesystem, and any third-party APIs.
Built for developers who care about observability and application resilience.
Install the package via Composer:
composer require mrtolouei/laravel-health-monitor
Publish the configuration and provider stub:
php artisan vendor:publish --tag=health-monitor-config
php artisan vendor:publish --tag=health-monitor-provider
The config file will be published to:
config/health-monitor.php
It contains two main sections:
You can enable/disable health checkers and configure each one:
'app-services' => [
'database' => [
'enabled' => true,
'inspector' => HealthMonitor\Monitors\DatabaseHealthChecker::class,
'arguments' => [
'connection' => config('database.default', 'sqlite')
],
],
'filesystem' => [
'enabled' => true,
'inspector' => HealthMonitor\Monitors\FilesystemHealthChecker::class,
'arguments' => [
'disk' => config('filesystems.default', 'local')
],
],
...
],
You can define any number of third-party HTTP APIs to monitor:
'third-party-services' => [
'json-test-api' => [
'enabled' => true,
'url' => 'https://jsonplaceholder.typicode.com/todos/1',
'method' => 'GET',
'headers' => [
'Accept' => 'application/json',
],
'auth' => null,
'timeout' => 5,
'expected_status' => 200,
],
],
Supported authentication types:
none
basic
(username & password)bearer
(token)ntlm
A Gate
is registered automatically to restrict access to non-local environments.
You can customize allowed users in config/health-monitor.php
:
'allowed_emails' => [
'admin@example.com',
'dev@example.com',
],
This package registers two routes (behind the viewHealthMonitor
gate):
Route | Method | Description |
---|---|---|
/api-service-health |
GET |
Returns JSON of health check status |
/service-health |
GET |
Shows a Blade view of statuses |
Create a new class that implements the HealthCheckerInterface
:
use HealthMonitor\Contracts\HealthCheckerInterface;
use HealthMonitor\Dto\HealthResult;
class CustomChecker implements HealthCheckerInterface {
public function monitor(): HealthResult {
return new HealthResult('My Checker', 'custom', true);
}
public function getConnectionDriver(): string|null {
return 'custom';
}
}
Then register it in the config file.
laravel-health-monitor/
├── config/
├── src/
│ ├── Contracts/
│ ├── Dto/
│ ├── Monitors/
│ ├── Facades/
│ ├── Factories/
│ └── HealthMonitorExecutor.php
└── routes/web.php
Developed and maintained by Ali Tolouei
Feel free to contribute or suggest features via issues and PRs!
This package is open-sourced software licensed under the MIT license.