Laravel Queue Monitor – Monitor Laravel job queues

Laravel Queue Monitor is a package that allows you to monitor and track the performance and execution of your Laravel job queues. It helps you visualize the status, success rate, and failure rate of your queued jobs, making it easier to manage background tasks and improve the overall performance of your application.

Key Features

  • Job Monitoring: Tracks the execution time, success, and failure rates of jobs.
  • Dashboard: Provides a visual dashboard for real-time monitoring of queue jobs.
  • Alerts: Set alerts for failed jobs or long-running jobs.
  • Job Retries: View and manage retries for failed jobs.
  • Customizable: Define custom monitoring thresholds and configure which jobs to monitor.
  • Database Storage: Stores job performance data in the database for detailed tracking.

Installation

To install the Laravel Queue Monitor package, use Composer:

bash

After installing the package, publish the configuration and migration files:

bash

Then, run the migration to create the necessary database tables:

bash
 

Configuration

After publishing the configuration file, you can customize the settings in config/queue-monitor.php. For example, you can specify which jobs to monitor or set thresholds for job execution time:

php
 

Enabling Monitoring for Jobs

To monitor a job, use the ShouldMonitor interface in your job class. This tells Laravel to track the execution of that particular job.

php
 

Viewing the Queue Monitor Dashboard

Once you have jobs being monitored, you can view the data through the Laravel Queue Monitor dashboard. By default, you can access the dashboard via a route like /queue-monitor.

To add the route to your application, include it in your web.php file:

php
 

Custom Monitoring and Alerts

You can set up custom alerts for jobs that exceed a specific execution time or fail a certain number of times. This helps you identify performance issues early on and take appropriate action.

Example: Setting Alerts for Long-Running Jobs

In your job class, you can specify a maximum allowed time for the job to run:

php
 

Handling Job Failures

In case of job failures, the monitor will track the number of failed attempts and retries. You can view this information in the dashboard and manually retry the job if needed.

Conclusion

Laravel Queue Monitor provides an excellent way to monitor and manage your queued jobs in Laravel. It helps track job performance, provides visual feedback through a dashboard, and offers tools to manage failed or long-running jobs effectively. By integrating this package, you can ensure that your background tasks run smoothly and troubleshoot issues quickly.

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top