In certain scenario's, your application can be in such a bad state, that it can't send any notifications anymore. A possible solution is to let Oh Dear monitor your checks, and let that service send notifications for you.
Using Oh Dear unlocks some more options: you'll be able to snooze notifications, and there are more delivery channels such as Telegram, Discord, MS Teams, Webhooks and more.
##Adding a health check endpoint to your Laravel app
Oh Dear will send an HTTP request to your application to a specific endpoint to get health check. Your application should respond with JSON containing the result of health checks.
You can add such an endpoint using the spatie/laravel-health package. To do this, must configure the ohdear_endpoint_key in the health config file.
You can publish that health with this command:
php artisan vendor:publish --tag="health-config"
These are some of the default values in the published health config file.
// in app/config/health.php/* * You can let Oh Dear monitor the results of all health checks. This way, you'll * get notified of any problems even if your application goes totally down. Via * Oh Dear, you can also have access to more advanced notification options. */'oh_dear_endpoint'=> ['enabled'=>false,/* * When this option is enabled, the checks will run before sending a response. * Otherwise, we'll send the results from the last time the checks have run. */'always_send_fresh_results'=>true,/* * The secret that is displayed at the Application Health settings at Oh Dear. */'secret'=>env('OH_DEAR_HEALTH_CHECK_SECRET'),/* * The URL that should be configured in the Application health settings at Oh Dear. */'url'=>'/oh-dear-health-check-results',],
To get started:
set the enabled config option to true
add a secret (we recommend putting it in the .env file, just like you would do for any application secret or password)
optionally customize the url where the health check endpoint will be registered.