Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Health Laravel Package

spatie/laravel-health

Monitor your Laravel app’s health by registering checks (disk space, etc.) with warning/fail thresholds. Get notified via mail or Slack when checks degrade, and extend with custom checks for proactive alerting.

View on GitHub
Deep Wiki
Context7

title: Registering your first check weight: 1

This package offers various checks to monitor different aspects of your application.

You can register the checks you want to run by passing an array with checks to Spatie\Health\Facades\Health::check().

Here's an example where we're going to register the UsedDiskSpace and DatabaseCheck. Typically, you would put this in a service provider of your own.

// typically, in a service provider

use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\UsedDiskSpaceCheck;
use Spatie\Health\Checks\Checks\DatabaseCheck;

Health::checks([
    UsedDiskSpaceCheck::new(),
    DatabaseCheck::new(),
]);

All registered checks will run when the RunHealthChecksCommand executes. If you followed the installation instructions, you have already scheduled that command to execute every minute.

If you haven't scheduled that command, you could run the checks and view the results via HTTP or JSON.

When a check results in a warning or a failure, a notification will be sent. You can learn more about notifications in the section on configuring notifications.

Though it's not required, you can store the results of the checks. This way, you can keep a history of the results in your own database.

Frequency

You can configure how often the checks should run. By default, the checks will run every minute. You can change this by calling a method that defines how often it should run, or passing a cron expression. Please refer to the Laravel documentation to see which options are available.

Health::checks([
    UsedDiskSpaceCheck::new()->daily(),
    DatabaseCheck::new(),
]);

Additionally, you might also choose the timezone in which the checks should run. By default, the timezone is set to UTC. You can change this by calling the timezone method.

Health::checks([
    UsedDiskSpaceCheck::new()->dailyAt('02:00')->timezone('America/Los_Angeles'),
    DatabaseCheck::new()->dailyAt('02:00'),
]);

The UsedDiskSpaceCheck check will run every day at 2AM Los Angeles time, whereas DatabaseCheck will run every day at 2AM UTC.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport