spatie/laravel-failed-job-monitor
Send instant notifications when Laravel queued jobs fail. Uses Laravel’s notification system with built-in Mail and Slack support, configurable via env/config, and easy install/publish. Great for monitoring production queues and alerting the right people.
Pros:
Cons:
.env updates).Illuminate\Notifications\Notifiable) to be properly configured for email/Slack.config:cache).FAILED_JOB_MONITOR_ENABLED) to toggle monitoring during rollouts.notificationFilter can address this, but requires upfront design.Illuminate\Queue\Queue, Illuminate\Bus\Dispatchable).guzzlehttp/guzzle and a Slack webhook URL.composer require spatie/laravel-failed-job-monitor guzzlehttp/guzzle
php artisan vendor:publish --tag=failed-job-monitor-config
.env with channels and recipients:
FAILED_JOB_MONITOR_ENABLED=true
FAILED_JOB_CHANNELS=mail,slack
FAILED_JOB_EMAILS=team@example.com
FAILED_JOB_SLACK_WEBHOOK_URL=https://hooks.slack.com/...
config/failed-job-monitor.php for advanced use cases (e.g., filters, custom notifiable).php artisan queue:work) and Horizon.guzzlehttp/guzzle (included in installation).Spatie\FailedJobMonitor\Notification or Notifiable for additional channels..env and config file changes to ensure consistency across environments.FAILED_JOB_MONITOR_ENABLED=true, queue workers are running, and notification channels are configured.max_attempts in jobs).notificationFilter logic) for onboarding.FAILED_JOB_CHANNELS=slack only for critical jobs).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Queue worker crashes | No notifications for failed jobs | Use supervisor/PM2 to restart workers. |
| Slack webhook URL invalid | Slack alerts fail silently | Validate webhook URL in CI/CD. |
| Email SMTP misconfiguration | Email alerts fail | Monitor mail queue; use a fallback channel. |
Custom notificationFilter error |
All notifications suppressed | Wrap filter logic in try-catch; log errors. |
| Database queue corruption | Failed jobs not logged | Use Redis/SQS for production; monitor queue health. |
| High alert volume | Alert fatigue, API throttling | Implement sampling or prioritization rules. |
throw new \Exception vs. `throw new \RuntimeExceptionHow can I help you explore Laravel packages today?