UptimeVanguard

Laravel application health checks

← All articles

Laravel application health checks

UptimeVanguard can read the health report of your application: disk space, queues, database, cache, scheduler and any other check your application runs. It reads the JSON format of spatie/laravel-health, the format that package serves on its Oh Dear endpoint.

1. Expose the endpoint in your Laravel application

Install and configure spatie/laravel-health and register the checks you need. Then enable its results endpoint in config/health.php:

'oh_dear_endpoint' => [
    'enabled' => true,
    'always_send_fresh_results' => true,
    'secret' => env('OH_DEAR_HEALTH_CHECK_SECRET'),
    'url' => '/oh-dear-health-check-results',
],

Set OH_DEAR_HEALTH_CHECK_SECRET to a long random value. The package refuses requests that do not send this secret in the oh-dear-health-check-secret header.

Keep the package's json_results_failure_status at its default of 200. If the endpoint answers failing checks with a 4xx or 5xx status, UptimeVanguard records the endpoint as unreachable and does not read the individual results.

2. Enable the check

  1. Open the site in UptimeVanguard and find Application health.
  2. Enter the endpoint URL, for example https://example.com/oh-dear-health-check-results. If you leave it empty, the site URL is used.
  3. Enter the same secret. UptimeVanguard sends it in the oh-dear-health-check-secret header.
  4. Click Enable. The first run is queued immediately; use Check now to run it again.

The check runs every five minutes. The endpoint must be publicly reachable over HTTP or HTTPS.

How results are evaluated

| Report | Result | |--------|--------| | Any check failed or crashed | Failing; an application-health issue alert is sent | | All checks ok | Healthy; a resolved alert is sent after a failure | | warning, skipped or unknown statuses, or no checks | Unknown; no alert changes | | HTTP error, invalid JSON, more than 1000 results, or results older than 15 minutes by finishedAt | Unreachable; no alert changes |

Application health alerts are informational: they do not open downtime incidents. If a site has assigned channels, tick the Application health alert type on each channel that should receive them. Only a verified healthy report resolves an earlier failure.

Other frameworks can use this check if their endpoint returns the same shape: a checkResults array whose entries have name, label, status, shortSummary and notificationMessage, and an optional Unix timestamp in finishedAt.