Download the PHP package lukaszaleckas/laravel-alerts without Composer
On this page you can find all versions of the php package lukaszaleckas/laravel-alerts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-alerts
Laravel Alerts
Installation
- Run:
Service provider should be automatically registered, if not add
to your application's app.php.
-
Publish
laravel-alerts.phpconfig file: - Schedule
RunChecksCommandin yourApp\Console\Kernelschedulemethod:
In the example above, we are running all of the checks registered in config file, every minute.
To run only specific alert checks, use the example below:
Creating alerts
Alert can be created using these steps:
- Create a new class anywhere in you project.
-
Extend it from
LaravelAlerts\Contracts\AbstractAlert: -
Add required method
buildAlertResultwhich should returnLaravelAlerts\DTOs\AlertResultDtoDTO. This DTO contains a boolean if alert was triggered, alert message and any additional context which will be appended to the alert's log. - Next, we need to register this alert in the config files
alertsarray. Below is an example of afailed_jobstable row count alert configuration:
Additional alert customization
Configuration parameters
To make alerts reusable, they can require configuration parameters. If you want to use this feature:
- Add
ConfigKeys::CONFIGin yoularavel-alerts.phpalerts' configuration and specify any number of parameters. (See an example above). - Override
LaravelAlerts\Contracts\AbstractAlertconfiguremethod, which will receive an array containing all of the parameters you added in the first step.
Logging options
Log level and log channels can be configured by overriding LaravelAlerts\Contracts\AbstractAlert
classes getAlertLeveland getLogChannels methods respectively.
Available alerts
This package contains some predefined alerts that you can use.
They are in the LaravelAlerts\Alerts namespace.
QueueSizeAlert
Alert is triggered if queue size, on a particular connection, exceeds threshold.
Configuration
connection(required) (string) - Queue connection namequeue(required) (string) - Queue namethreshold(required) (int) - Queue size (job count) threshold
TableSizeAlert
Alert is triggered if database table size exceeds threshold.
Configuration
connection(required) (string) - Database connection nametable_name(required) (string) - Table namethreshold(required) (int) - Table size (row count) threshold