https://github.com/chris-ware/pulse-health-check
Combine the power of Laravel Pulse with Spatie's Health Checks
https://github.com/chris-ware/pulse-health-check
Last synced: 7 months ago
JSON representation
Combine the power of Laravel Pulse with Spatie's Health Checks
- Host: GitHub
- URL: https://github.com/chris-ware/pulse-health-check
- Owner: chris-ware
- License: mit
- Created: 2023-12-12T22:36:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-12-11T14:04:23.000Z (7 months ago)
- Last Synced: 2025-12-12T17:36:00.126Z (7 months ago)
- Language: PHP
- Size: 58.6 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-pulse - Health Checks - A Laravel Pulse card for [Spatie Laravel Health](https://spatie.be/docs/laravel-health/v1/introduction) (Cards / External Services)
README
# Pulse Health Checks
[](https://packagist.org/packages/chris-ware/pulse-health-check)
[](https://github.com/chris-ware/pulse-health-check/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/chris-ware/pulse-health-check/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/chris-ware/pulse-health-check)
Combine the power of Laravel Pulse with Spatie's Health Checks
## Installation
You can install the package via composer:
```bash
composer require chris-ware/pulse-health-check
```
## Usage
### Cache Hit Ratio Check
This check will warn or fail if the cache hit ratio hits a certain percentage threshold. By default, it will fail at 10% hit ratio and warn at 25%.
```php
use ChrisWare\PulseHealthCheck\Checks\PulseCacheHitRatioCheck;
PulseCacheHitRatioCheck::new();
```
Configure the failure and warning levels:
```php
use ChrisWare\PulseHealthCheck\Checks\PulseCacheHitRatioCheck;
PulseCacheHitRatioCheck::new()->failWhenSizeRatioBelow(25)->warnWhenSizeRatioBelow(50);
```
### Generic Check
This generic check will accommodate most basic circumstances for Pulse aggregates. Every check must have a defined `for` method on it for it to understand which aggregate type to use.
Example for slow query aggregation:
```php
use ChrisWare\PulseHealthCheck\Checks\PulseCheck;
PulseCheck::new()
->for('slow_query')
->failWhenAbove(5)
->warnWhenAbove(3)
->interval(\Carbon\CarbonInterval::minutes(5));
```
Example for user request aggregation:
```php
use ChrisWare\PulseHealthCheck\Checks\PulseCheck;
PulseCheck::new()
->for('user_request')
->aggregate('count')
->failWhenAbove(500)
->warnWhenAbove(300)
->interval(\Carbon\CarbonInterval::minutes(5));
```
#### Available methods
**for**: Determine the aggregation type to use
**aggregate**: Determine the aggregation value to use (defaults to `max`)
**failWhenAbove**: Set the value to fail if greater than or equal to
**failWhenBelow**: Set the value to fail if less than or equal to
**warnWhenAbove**: Set the value to warn if greater than or equal to
**warnWhenBelow**: Set the value to warn if less than or equal to
**interval**: The CarbonInterval for aggregations to be evaluated (defaults to 1 hour)
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits
- [Chris Ware](https://github.com/chris-ware)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.