Skip to content

Artisan Commands

Artisan Commands

Laravel Queue Metrics provides Artisan commands for maintenance and monitoring.

Available Commands

Record trend data for historical analysis.

php artisan queue-metrics:record-trends

Purpose: Records queue depth and worker efficiency snapshots for trend analysis.

Schedule Example:

// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
    $schedule->command('queue-metrics:record-trends')
        ->everyFiveMinutes();
}

queue-metrics:detect-stale-workers

Detect and mark stale workers.

php artisan queue-metrics:detect-stale-workers

Purpose: Identifies workers that haven't sent heartbeats recently and marks them as stale.

Options:

# Custom stale threshold (default: 60 seconds)
php artisan queue-metrics:detect-stale-workers --threshold=180

Schedule Example:

protected function schedule(Schedule $schedule)
{
    $schedule->command('queue-metrics:detect-stale-workers')
        ->everyMinute();
}
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
    // Trend recording
    $schedule->command('queue-metrics:record-trends')
        ->everyFiveMinutes();

    // Worker monitoring
    $schedule->command('queue-metrics:detect-stale-workers')
        ->everyMinute();
}

Next Steps