Download the PHP package cboxdk/laravel-queue-metrics without Composer
On this page you can find all versions of the php package cboxdk/laravel-queue-metrics. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cboxdk/laravel-queue-metrics
More information about cboxdk/laravel-queue-metrics
Files in cboxdk/laravel-queue-metrics
Package laravel-queue-metrics
Short Description Production-ready Laravel queue monitoring with metrics, analytics, and insights
License MIT
Homepage https://github.com/cboxdk/laravel-queue-metrics
Informations about the package laravel-queue-metrics
Cbox Queue Metrics
Production-ready queue monitoring and metrics collection for Laravel applications.
Queue Metrics for Laravel provides deep observability into your Laravel queue system with minimal overhead. Track job execution, monitor worker performance, analyze trends, and export to Prometheusβall with zero configuration required.
Why Queue Metrics for Laravel?
- π Zero Configuration - Works out-of-the-box
- β‘ Minimal Overhead - ~1-2ms per job
- π Rich Insights - Duration, memory, CPU, throughput, trends
- π― Production Ready - Battle-tested at scale
- π Extensible - Events for customization and reactive monitoring
- π Prometheus Ready - Native metrics export
- ποΈ DX First - Clean facade API and comprehensive docs
Quick Example
Documentation
π Full Documentation β
π Need Deep Insight and Replay Capability?
While this package provides a high-level overview of your queue's health and performance via aggregated metrics, Queue Monitor for Laravel allows you to dive into individual job executions.
We recommend installing it if you need:
- π΅οΈββοΈ Debugging: View exact arguments (payload) for failed jobs and read the full stack trace.
- π Job Replay: Restart failed jobs directly from the database with a single click or command.
- π€ Customer Support: Look up jobs based on tags (e.g., find all jobs for a specific user).
- π Audit Log: Complete history of every job execution, including which server/PID processed it.
The two packages are designed to work together: Metrics tells you that something is wrong, while Monitor tells you what is wrong and lets you fix it.
Getting Started
- Installation - Get up and running
- Quick Start - 5-minute walkthrough
- Requirements - PHP, Laravel, and dependencies
- Configuration - Customize behavior
Integration
- Facade API - Developer interface
- HTTP API - REST endpoints
- Prometheus - Monitoring integration
Extensibility
- Events - React to metrics changes
- Architecture - How it works
Real-World Examples
- Artisan Commands - CLI tools
- Performance Tuning - Optimizing for scale
Installation
That's it! The package auto-registers and starts collecting metrics immediately.
For database storage, run migrations:
β Full installation guide
Key Features
Job Metrics
Track execution time, memory usage, CPU time, throughput, and failure rates per job class with percentile statistics (P50, P95, P99).
Queue Health
Monitor queue depth, processing rates, failure rates, and health scores with automatic issue detection.
Worker Monitoring
Real-time worker status, resource consumption, efficiency metrics, and stale worker detection.
Trend Analysis
Historical analysis with linear regression, forecasting, and anomaly detection for proactive insights.
Baseline Comparison
Automatic baseline calculation to detect performance degradation and regressions.
Flexible Storage
Redis (fast, in-memory) or Database (persistent) backends with automatic TTL cleanup.
Prometheus Export
Native Prometheus metrics endpoint for Grafana dashboards and alerting.
OpenTelemetry via laravel-telemetry
When cboxdk/laravel-telemetry is installed (requires Laravel 12+), queue metrics automatically publishes the state telemetry cannot see on its own β no configuration required (disable with QUEUE_METRICS_TELEMETRY_ENABLED=false):
| Metric | Type | Unit | Labels |
|---|---|---|---|
queue_metrics.queue.depth |
gauge | {jobs} |
connection, queue, state (pending/scheduled/reserved) |
queue_metrics.queue.oldest_job.age |
gauge | s |
connection, queue |
queue_metrics.queue.throughput |
gauge | {jobs}/min |
connection, queue |
queue_metrics.queue.failure_rate |
gauge | % |
connection, queue |
queue_metrics.queue.active_workers |
gauge | {workers} |
connection, queue |
queue_metrics.queue.health_score |
gauge | 1 |
connection, queue |
queue_metrics.workers.count |
gauge | {workers} |
state (busy/idle) |
queue_metrics.workers.utilization |
gauge | % |
window (current/lifetime) |
queue_metrics.workers.efficiency |
gauge | % |
β |
queue_metrics.baseline.duration |
gauge | ms |
connection, queue |
queue_metrics.baseline.memory |
gauge | MBy |
connection, queue |
queue_metrics.baseline.cpu |
gauge | % |
connection, queue |
queue_metrics.baseline.confidence |
gauge | 1 |
connection, queue |
queue_metrics.health.changes |
counter | β | connection, queue, severity |
queue_metrics.queue.depth_threshold.exceeded |
counter | β | connection, queue |
queue_metrics.jobs.debounced |
counter | β | job.name, queue |
queue_metrics.baseline.recalculations |
counter | β | connection, queue, significant |
Severe health changes, depth threshold breaches and scaling recommendations are additionally emitted as structured OTLP events. Per-job durations, memory and outcome counters are deliberately not re-exported β laravel-telemetry's own queue instrumentation already covers those.
Running both the built-in Prometheus exporter and the telemetry integration exposes the same queue state twice β php artisan queue-metrics:doctor diagnoses your setup and warns about double exposure.
RESTful API
Complete HTTP API for integration with custom dashboards and monitoring tools.
Events
Extensible architecture with events for reactive monitoring and notifications.
Requirements
- PHP 8.3+
- Laravel 11.0, 12.0, or 13.0+
- Redis or Database for metrics storage
Note: Laravel 12.19+ is recommended for most accurate queue metrics (Laravel PR #56010). Earlier versions use driver-specific implementations.
Configuration
Storage Drivers
Redis (default, recommended)
Redis is the recommended driver for all workloads. It handles high-frequency metrics writes with minimal overhead.
Database
For applications without Redis infrastructure, a database driver is available. This stores metrics in 4 database tables using the same schema as your application database.
Run the migration to create the metrics tables:
Important: The database driver is designed for low-scale workloads (< 10 workers). At higher scale, metrics writes create contention on the same database your queue jobs use. Use Redis for production with moderate to high workloads.
Recommended setting for database driver: Set
QUEUE_METRICS_MAX_SAMPLES=500to keep table sizes manageable.
The database cleanup command runs automatically every minute when using the database driver, removing expired data and trimming sample tables.
API Authentication
Scheduled Commands
The package automatically schedules necessary maintenance tasks. You can disable or configure this behavior in config/queue-metrics.php:
If you prefer to manually schedule commands in your Console/Kernel.php (or routes/console.php), simply set 'enabled' => false.
β Complete configuration reference
Usage Examples
Monitor Job Performance
Check Queue Health
React to Events
Multi-Tenancy Integration
β More examples
API Endpoints
β Complete API reference
Prometheus Integration
Query metrics:
β Prometheus setup guide
Architecture
Queue Metrics for Laravel uses a clean, layered architecture:
- Event Listeners β Capture Laravel queue events
- Actions β Business logic for recording metrics
- Repositories β Data access abstraction
- Storage Drivers β Pluggable backends (Redis/Database)
- Services β High-level business operations
- DTOs β Type-safe, immutable data structures
- Events β Reactive monitoring and notifications
β Architecture deep dive
Performance
- Per-job overhead: ~1-2ms (Redis), ~5-15ms (Database)
- Memory overhead: ~5-10MB package classes, ~1-2KB per job record
- Tested throughput: 10,000+ jobs/minute
- Storage: Auto-cleanup via TTL (Redis) or manual cleanup (Database)
β Performance tuning guide
Testing
Contributing
Please see the GitHub repository to open issues or pull requests.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Sylvester Damgaard
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
π Read the full documentation β
All versions of laravel-queue-metrics with dependencies
cboxdk/system-metrics Version ^3.0
illuminate/contracts Version ^11.0|^12.0|^13.0
spatie/laravel-package-tools Version ^1.16
spatie/laravel-prometheus Version ^1.3