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: Queue weight: 16

This check will make sure that queued jobs are running. This check works by dispatching a test job (this will be done via a scheduled command), and verify if that test job is handled on time.

This check relies on cache.

Usage

First, you must schedule the Spatie\Health\Commands\DispatchQueueCheckJobsCommand to run every minute. This command will dispatch a very light job on the queue you wish to monitor.

For Laravel 10 and earlier

// in app/Console/Kernel.php
use \Spatie\Health\Commands\DispatchQueueCheckJobsCommand;

protected function schedule(Schedule $schedule) {
    // your other commands

    $schedule->command(DispatchQueueCheckJobsCommand::class)->everyMinute();
}

For Laravel 11 and newer

// in routes/console.php

use Illuminate\Support\Facades\Schedule;
use Spatie\Health\Commands\DispatchQueueCheckJobsCommand;

// your other scheduled commands

Schedule::command(DispatchQueueCheckJobsCommand::class)->everyMinute();

Next, you must register a QueueCheck. When providing no options, this check will monitor the default queue, and will fail if the job dispatched by the DispatchQueueCheckJobsCommand isn't handled within 5 minutes.

use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\QueueCheck;

Health::checks([
    QueueCheck::new(),
]);

You can monitor a different queue, by tacking on onQueue.

use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\QueueCheck;

Health::checks([
    QueueCheck::new()->onQueue('email'),
]);

The onQueue method can accept multiple queues.

use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\QueueCheck;

Health::checks([
    QueueCheck::new()->onQueue(['email', 'payment']),
]);

Customizing job time

By default, the QueueCheck will fail when the job dispatched by DispatchQueueCheckJobsCommand isn't handled within 5 minutes. You can customize the amount of minutes using the failWhenHealthJobTakesLongerThanMinutes method.

QueueCheck::new()->failWhenHealthJobTakesLongerThanMinutes(10),

Customize the cache store

This queue check relies on cache to work. The test job dispatched by DispatchQueueCheckJobsCommand will write a timestamp in that cache that will be verified by QueueCheck.

use Spatie\Health\Facades\Health;
use Spatie\Health\Checks\Checks\QueueCheck;

Health::checks([
    QueueCheck::new()->useCacheStore('your-custom-store-name'),
]);
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