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 Failed Job Monitor Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Leverages Laravel’s Native Systems: Integrates seamlessly with Laravel’s built-in queue system and notification framework, reducing architectural overhead.
    • Extensible Design: Supports customization of notifications, notifiables, and filtering logic via configuration or class overrides.
    • Decoupled: Does not modify core Laravel behavior; operates as a middleware-like observer for failed jobs.
    • Multi-Channel Support: Out-of-the-box support for email and Slack, with potential for additional channels (e.g., PagerDuty, SMS) via custom notifications.
    • Horizon Compatibility: Enhances visibility into failed jobs when using Laravel Horizon, including direct links to Horizon’s UI for debugging.
  • Cons:

    • Dependency on Laravel’s Queue System: Limited to Laravel applications using queues (e.g., Redis, database, SQS). Not applicable for non-queue-based workflows.
    • Notification System Dependency: Relies on Laravel’s notification system, which may require additional setup (e.g., mail drivers, Slack webhooks).
    • No Retry Mechanism: Only monitors failures; does not automatically retry jobs (requires integration with Laravel’s retry logic or external tools like Supervisor).

Integration Feasibility

  • Low-Coupling: Can be added to existing Laravel applications with minimal code changes (primarily configuration).
  • Queue Worker Compatibility: Works with all Laravel-supported queue drivers (database, Redis, Amazon SQS, etc.).
  • Horizon-Specific Features: If using Laravel Horizon, the package provides enhanced visibility (e.g., direct links to failed jobs in Horizon’s dashboard).
  • Customization Points:
    • Override default notification classes (Notification and Notifiable).
    • Filter notifications via a callable (e.g., exclude specific job classes or failures).
    • Extend or replace the default email/Slack templates.

Technical Risk

  • Minimal Risk:
    • Stability: Actively maintained (last release in 2026), with a mature codebase (1000+ stars, MIT license).
    • Backward Compatibility: Supports Laravel 9–13 and PHP 8+, with clear deprecation paths for older versions.
    • Performance Impact: Minimal overhead; notifications are triggered only on job failures.
  • Potential Risks:
    • Notification Spam: Unfiltered notifications could overwhelm teams if not configured carefully (mitigated via notificationFilter).
    • Configuration Errors: Misconfigured .env variables (e.g., invalid Slack webhook) could prevent notifications from sending.
    • Horizon-Specific Features: If not using Horizon, some UI/UX features (e.g., direct links to failed jobs) may not apply.

Key Questions for TPM

  1. Queue Infrastructure:

    • What queue drivers are used in the application (e.g., Redis, database)? Are there any constraints (e.g., SQS with limited visibility timeouts)?
    • Is Laravel Horizon used for queue monitoring? If so, how should failed job notifications complement or replace existing Horizon alerts?
  2. Notification Workflow:

    • Who are the intended recipients of failure notifications (e.g., developers, on-call engineers)? Are there SLAs for response times?
    • Are there existing notification systems (e.g., PagerDuty, Opsgenie) that should integrate with this package? If so, how would custom notifications be implemented?
  3. Customization Needs:

    • Are there specific job classes or failure types that should not trigger notifications (e.g., transient failures like rate limits)?
    • Should notifications include additional context (e.g., job payload, user context, or system metrics)?
  4. Operational Constraints:

    • Are there rate limits or throttling requirements for notifications (e.g., max 5 alerts/hour)?
    • How should notifications be handled during deployment windows or maintenance periods?
  5. Testing and Validation:

    • What are the acceptance criteria for a successful notification (e.g., delivery rate, content accuracy)?
    • Should synthetic failed jobs be injected into the queue for validation purposes?
  6. Scaling Considerations:

    • How will notification volume scale with increased job throughput? Are there plans for distributed queue workers?
    • Should notifications be batched or prioritized (e.g., critical jobs first)?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Ideal for Laravel applications using queues (database, Redis, SQS, etc.), especially those already leveraging Laravel’s notification system.
  • Queue Workers: Compatible with all Laravel queue workers (e.g., php artisan queue:work, Supervisor, Forge, or cloud-based workers like AWS Fargate).
  • Horizon Integration: Enhances Horizon’s built-in failure tracking with additional channels (email/Slack) and direct links to failed jobs.
  • Third-Party Extensions:
    • Slack: Requires guzzlehttp/guzzle for webhook calls.
    • Email: Requires a configured mail driver (e.g., SMTP, Mailgun, SendGrid).
    • Custom Channels: Can extend to other services (e.g., Twilio for SMS, PagerDuty for alerts) via custom notifications.

Migration Path

  1. Prerequisites:

    • Ensure the Laravel application meets the package’s requirements (PHP 8+, Laravel 9+).
    • Configure queue workers (e.g., Redis, database) and verify job failures are detectable.
    • Set up notification channels (e.g., mail driver, Slack webhook).
  2. Installation:

    composer require spatie/laravel-failed-job-monitor
    composer require guzzlehttp/guzzle  # Only if using Slack
    php artisan vendor:publish --tag=failed-job-monitor-config
    
  3. Configuration:

    • Update .env with notification channels and recipients:
      FAILED_JOB_MONITOR_ENABLED=true
      FAILED_JOB_CHANNELS=mail,slack
      FAILED_JOB_EMAILS=devops@example.com,oncall@example.com
      FAILED_JOB_SLACK_WEBHOOK_URL=https://hooks.slack.com/...
      
    • Customize config/failed-job-monitor.php as needed (e.g., override notification classes, add filters).
  4. Testing:

    • Manually trigger a failed job (e.g., by throwing an exception in a job’s handle() method).
    • Verify notifications are received via configured channels.
    • Test edge cases (e.g., disabled monitor, filtered notifications).
  5. Deployment:

    • Enable the monitor in production (FAILED_JOB_MONITOR_ENABLED=true).
    • Monitor notification delivery and adjust filters/recipients as needed.

Compatibility

  • Laravel Versions: Supports 9–13 (as of 2026). Drop older versions (5.8–8) if upgrading.
  • Queue Drivers: Works with all Laravel-supported drivers (database, Redis, SQS, etc.).
  • Horizon: Adds value if Horizon is used; otherwise, notifications remain channel-agnostic.
  • Custom Notifications: Extendable to support additional channels (e.g., SMS, push notifications) via Laravel’s notification system.

Sequencing

  1. Phase 1: Pilot (Development/Staging):

    • Install and configure the package in a non-production environment.
    • Test with a subset of critical jobs to validate notifications.
    • Refine filters and recipients based on feedback.
  2. Phase 2: Rollout (Production):

    • Enable the monitor in production with a gradual rollout (e.g., start with email-only).
    • Monitor notification volume and adjust thresholds/filters.
    • Integrate with existing alerting tools (e.g., forward Slack messages to PagerDuty).
  3. Phase 3: Optimization:

    • Add custom logic (e.g., dynamic recipient lists, severity-based routing).
    • Automate validation (e.g., synthetic job failures for health checks).

Operational Impact

Maintenance

  • Low Effort:
    • Configuration-Driven: Changes to notification channels/recipients require only .env or config file updates.
    • No Core Changes: Does not modify application logic; updates are versioned via Composer.
  • Monitoring:
    • Track notification delivery success/failure (e.g., via mail logs or Slack webhook responses).
    • Log exceptions (e.g., failed Slack webhook calls) for debugging.

Support

  • Troubleshooting:
    • Common Issues:
      • Notifications not sending: Verify .env variables, queue worker health, and notification channel configurations.
      • Duplicate notifications: Check for job retries or queue worker restarts.
      • Slack/email failures: Validate webhook URLs and mail driver settings.
    • Debugging Tools:
      • Laravel’s failed:table for inspecting failed jobs.
      • Horizon’s UI for visualizing queue failures.
      • Package logs (e.g., storage/logs/laravel.log) for errors.
  • Escalation Path:
    • For critical failures, bypass filters to ensure notifications reach the team.
    • Integrate with existing support workflows (e.g., Jira tickets from Slack alerts).

Scaling

  • Performance:
    • **Min
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony