laravel-horizon
Auto-invoked skill
Monitor and manage Redis queues with dashboard and metrics
Trigger Keywords
This skill automatically activates when Claude detects these keywords:
horizon
queue dashboard
failed jobs
queue metrics
worker status
redis queue
Overview
The laravel-horizon skill provides expertise for Redis queue monitoring and management using Laravel Horizon. It covers dashboard setup, worker configuration, metrics, notifications, and failed job management.
What This Skill Provides
- Dashboard Setup - Install and configure Horizon dashboard
- Worker Configuration - Multi-queue and auto-scaling workers
- Metrics & Monitoring - Queue throughput and wait times
- Notifications - Slack/email alerts for failures
- Job Tags - Organize and filter jobs
- Failed Jobs - Retry and manage failed jobs
Quick Start
# Install Horizon
composer require laravel/horizon
php artisan horizon:install
php artisan migrate
# Run Horizon
php artisan horizon
Worker Configuration
<?php
// config/horizon.php
'environments' => [
'production' => [
'supervisor-high' => [
'connection' => 'redis',
'queue' => ['high'],
'balance' => 'simple',
'maxProcesses' => 5,
'tries' => 3,
],
'supervisor-default' => [
'connection' => 'redis',
'queue' => ['default'],
'balance' => 'auto',
'maxProcesses' => 10,
'minProcesses' => 1,
],
'supervisor-low' => [
'connection' => 'redis',
'queue' => ['low'],
'balance' => 'simple',
'maxProcesses' => 3,
],
],
],
Authorization
<?php
// app/Providers/HorizonServiceProvider.php
protected function gate(): void
{
Gate::define('viewHorizon', function ($user) {
return in_array($user->email, [
'admin@example.com',
]);
});
}
Notifications
// Send alerts on long wait times
Horizon::routeSlackNotificationsTo(
env('SLACK_WEBHOOK_URL'),
'#horizon-alerts'
);
Horizon::routeLongWaitTimeNotificationsTo(
env('SLACK_WEBHOOK_URL'),
60 // seconds
);
Job Tags
final class ProcessOrder implements ShouldQueue
{
public function tags(): array
{
return [
'order',
'order:'.$this->order->id,
'user:'.$this->order->user_id,
];
}
}
Supervisor Configuration
[program:horizon]
process_name=%(program_name)s
command=php /var/www/html/artisan horizon
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/horizon.log
stopwaitsecs=3600
Common Pitfalls
- Not using Supervisor - Horizon needs a process manager
- Forgetting to terminate on deploy - Run
php artisan horizon:terminate - Missing authorization gate - Dashboard is public without it
- Wrong Redis configuration - Ensure
QUEUE_CONNECTION=redis - Not monitoring wait times - Set up Slack notifications
Best Practices
- Use Supervisor for process management
- Configure auto-scaling for production
- Set up Slack/email notifications
- Monitor queue wait times
- Tag jobs for filtering
- Terminate Horizon on deploy
- Set appropriate memory limits
Related Skills
- laravel-queue - Queue and job implementation
- laravel-deploy - Production deployment