rob-lester-jr04 / laravel-health-expansion
An expansion pack for Spatie Laravel Health package
Installs: 5 386
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- guzzlehttp/guzzle: ^7.7
- mailgun/mailgun-php: ^3.5
- nesbot/carbon: ^2.67|^3.0
- spatie/laravel-health: ^1.22
Requires (Dev)
- orchestra/testbench: ^6.23|^7.6|^8.0
- phpunit/phpunit: ^10.2
README
Using this package to add more health checks to Spatie Health Checks for Laravel.
Installation
composer require rob-lester-jr04/laravel-health-expansion
Laravel will automatically register the service provider.
Here's an example where we'll monitor errors in PaperTrail.
// typically, in a service provider use Spatie\Health\Facades\Health; use Lester\Health\Checks\Checks\PaperTrailCheck; Health::checks([ PaperTrailCheck::new() ->onSystem('my-system-1'), ]);
By default, this will report a failure if there are more than 20 errors in the default time frame (10 minutes). It will report a warning if there are more than 10, and it will report as ok if the error count is under 10. The thresholds can be changed with the following methods:
...highCount(); ...lowCount(); // Change time frame (in minutes) ...lastMinutes();
Available Checks
This package also contains the following checks:
- MailgunDomainCheck
- This check will get the status for your mailgun domain(s) so you can monitor if mailgun has flagged your deliverability.
- ApiCheck
- This check allows you to get the laravel health from another application. Useful for creating a permenant dashboard screen that monitors all your other systems.
- PaperTrailCheck
- Scans PaperTrail logs for a set number of errors in a set time frame.
Using the MailGun domain check
First, set the API key in the .env
file.
MAILGUN_SECRET=########
Then enable the check in the service provider
use Spatie\Health\Facades\Health; use Lester\Health\Checks\Checks\MailgunDomainCheck; Health::checks([ // ... MailgunDomainCheck::new() ->domain('mg.example.com'), // ... ]);
Testing
composer test