Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthewyeend/queuemonitor
A Laravel package for Queue Monitoring
https://github.com/matthewyeend/queuemonitor
composer composer-package laravel laravel-11 laravel-package monitor monitoring queue queue-monitor
Last synced: 3 days ago
JSON representation
A Laravel package for Queue Monitoring
- Host: GitHub
- URL: https://github.com/matthewyeend/queuemonitor
- Owner: MatthewYeend
- License: mit
- Created: 2025-01-14T14:23:25.000Z (11 days ago)
- Default Branch: main
- Last Pushed: 2025-01-21T22:19:55.000Z (3 days ago)
- Last Synced: 2025-01-21T23:18:45.325Z (3 days ago)
- Topics: composer, composer-package, laravel, laravel-11, laravel-package, monitor, monitoring, queue, queue-monitor
- Language: PHP
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Queue Monitor
A Laravel package for real-time monitoring of queues with stats on processing time, failed jobs, and retry status.
---
## Features
- Real-time queue monitoring.
- Detailed stats on processing time and retries.
- Notifications for failed jobs.---
## Installation
1. Require the package via Composer
```bash
composer require MattYeend/queue-monitor
```
2. Publish the configuration, views, and migrations:
```bash
php artisan vendor:publish --provider="MattYeend\QueueMonitoring\QueueMonitoringServiceProvider"
```
3. Run the migrations to create the necessary database table:
```bash
php artisan migrate
```
4. Access the dashboard at `/queue-monitor` (or a custom route if configured)---
## Usage
1. Queue Monitoring Dashboard
Once installed, the package provides a monitoring dashboard accessible at `/queue-monitor` (or a custom route specified in `config/queue-monitor.php`). The dashboard displays:
- The list of queues being monitored.
- The number of jobs processed.
- The number of failed jobs.
- The average processing time for each queue.
2. Automatically Updating Queue Statistics
To update queue statistics after job processing:
- Inject the `QueueMonitorService` into your job classes or relevant services.
- Use the `updateQueueStatus` method to log the queue name, processing time, and failure status.
Example Integration in a Job:
```php
use MattYeend\QueueMonitoring\Services\QueueMonitorService;class ExampleJob implements ShouldQueue
{
public function handle(QueueMonitorService $service)
{
$queueName = 'example-queue';
$startTime = microtime(true);try {
// Performs job processing
} catch (\Exception $e) {
$service->updateQueueStatus($queueName, 0, true); // Log a failed job
throw $e;
}$endTime = microtime(true);
$processingTime = ($endTime - $StartTime) * 1000; // Convert to milliseconds
$service->updateQueueStatus($queueName, $processingTime, false); // Log a successful job
}
}
```
3. Customising the Dashboard
You can customise the dashboard view by modifying the published Blade file
`resources/views/vendor/queue-monitor/dashboard.blade.php`
4. Custom Route
The change the route for the dashboard, edit the `dashboard_route` value in the configuration file
`'dashboard_route' => '/admin/queue-status'`
5. Notifications for Failed Jobs
To enable email notifications for failed jobs:
- Add the following to your `.env` file:
`[email protected]`
- The configured email address will receive alerts whenever a job fails in a monitored queue.---
## Configuration
### `.env` File
To configure email notifications for failed jobs, add the following line to your `.env` file:
```ini
[email protected]
```
This will be used to send notifications for failed jobs. If not set, it will default to `[email protected]`.
### Custom Dashboard Route
To change the default URL route, modify the `config/queue-monitor.php` file. For example
```php
'dashboard_route' => '/admin/queue-status',
```---
## Tests
### Setting Up the Test Environment
1. Install Dependencies
```bash
composer install
```
2. Configure your environment
Ensure your `.env` file is set up for testing. By default, the `TestCase` class configures an in-memory SQLite database for testing, so no additional setup is required.### Running the Test
1. Run all tests
```bash
php artisan test
```
or:
```bash
./vendor/bin/phpunit
```---
## License
This package is licensed under the MIT License.---
## Contributing
Feel free to fork the repository and submit pull requests for improvements or new features!