PHPackages                             lstables/laravel-queue-watcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. lstables/laravel-queue-watcher

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

lstables/laravel-queue-watcher
==============================

Real-time queue job monitoring, debugging, and failure analysis for Laravel

v1.0.4(4mo ago)03MITPHPPHP ^8.1|^8.2|^8.3

Since Jan 2Pushed 4mo agoCompare

[ Source](https://github.com/lstables/laravel-queue-watcher)[ Packagist](https://packagist.org/packages/lstables/laravel-queue-watcher)[ RSS](/packages/lstables-laravel-queue-watcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (6)Used By (0)

Laravel Queue Watcher
=====================

[](#laravel-queue-watcher)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dbb1b82056fc750d7dc36ab97f86536a04aaf7d6f03b7f75f3ba596f5630d596/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f75726e616d652f6c61726176656c2d71756575652d776174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yourname/laravel-queue-watcher)[![Total Downloads](https://camo.githubusercontent.com/69c1c8586338fc9b5b6bceb0198bda1dbc1041ae21a3201342bc33cd4eaf836e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796f75726e616d652f6c61726176656c2d71756575652d776174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yourname/laravel-queue-watcher)

**Real-time queue job monitoring, debugging, and failure analysis for Laravel.** Goes far beyond what Laravel Horizon offers - works with ALL queue drivers, provides instant failure notifications, enables job replay, and helps you understand WHY jobs fail.

The Problem
-----------

[](#the-problem)

- ❌ Jobs fail silently in production
- ❌ Hard to debug why a job failed
- ❌ Can't easily replay failed jobs
- ❌ No visibility into job performance
- ❌ Laravel Horizon only works with Redis
- ❌ Can't compare failed jobs with successful ones

The Solution
------------

[](#the-solution)

✅ **Real-time monitoring** - See jobs fail the moment they happen ✅ **Works with ALL queue drivers** - Database, Redis, SQS, Beanstalkd, etc. ✅ **Job replay** - Retry failed jobs with one command ✅ **Failure analysis** - Compare failed jobs with successful ones ✅ **Performance tracking** - See execution time, memory usage, query count ✅ **Dependency visualization** - Track job chains and batches ✅ **Health monitoring** - Get a health score for your queue system

Installation
------------

[](#installation)

```
composer require lstables/laravel-queue-watcher
```

Publish and run migrations:

```
php artisan vendor:publish --tag=queue-watcher-migrations
php artisan migrate
```

Optional: Publish config:

```
php artisan vendor:publish --tag=queue-watcher-config
```

Quick Start
-----------

[](#quick-start)

### 1. Inspect Failed Jobs

[](#1-inspect-failed-jobs)

```
# List all failed jobs from last 24 hours
php artisan queue:inspect --failed

# Inspect a specific job
php artisan queue:inspect 123

# Filter by job class
php artisan queue:inspect --job="App\Jobs\ProcessOrder"

# Show only slow jobs
php artisan queue:inspect --slow
```

**Output:**

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  JOB DETAILS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ID                   123
UUID                 abc-123-def
Job Name             App\Jobs\ProcessOrder
Status               ✗ Failed

Queue                default
Connection           database
Attempts             3

Performance:
  Execution Time     5.2s
  Memory Usage       12.5 MB
  Queries            47

  ⚠ This job is slower than average

Exception:
SQLSTATE[23000]: Integrity constraint violation...

```

### 2. Replay Failed Jobs

[](#2-replay-failed-jobs)

```
# Replay a single job
php artisan queue:replay 123

# Replay all failed jobs of a specific type
php artisan queue:replay --job="App\Jobs\ProcessOrder"

# Replay jobs from a time range
php artisan queue:replay --from="2024-01-01" --to="2024-01-02"

# Replay all failed jobs (with confirmation)
php artisan queue:replay --all --limit=50
```

**Output:**

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  REPLAY RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✓ Success            47
✗ Failed             3

Errors:
  • Job 125: Job class does not exist
  • Job 130: Payload too large to store

```

### 3. Compare Failed vs Successful Jobs

[](#3-compare-failed-vs-successful-jobs)

This is the **killer feature** - understand WHY a job failed by comparing it with successful runs:

```
php artisan queue:compare 123
```

**Output:**

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  JOB COMPARISON ANALYSIS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Failed Job:
  ID               123
  Job              App\Jobs\ProcessOrder
  Failed At        2024-01-02 10:30:00
  Attempts         3

Performance Comparison:
┌─────────────────┬────────────┬────────────────┬────────────┐
│ Metric          │ Failed Job │ Avg Successful │ Difference │
├─────────────────┼────────────┼────────────────┼────────────┤
│ Execution Time  │ 5.2s       │ 1.8s          │ +189%      │
│ Memory Usage    │ 12.5 MB    │ 4.2 MB        │ +198%      │
│ Queries         │ 47         │ 12            │ +292%      │
└─────────────────┴────────────┴────────────────┴────────────┘

💡 Recommendations:
  1. Job took significantly longer than usual - check for timeouts
  2. Memory usage is unusually high - check for memory leaks
  3. Query count is 4x normal - check for N+1 queries

```

### 4. Queue Health Dashboard

[](#4-queue-health-dashboard)

```
php artisan queue:stats
```

**Output:**

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  QUEUE STATISTICS (Last 24 hours)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Health Score         85/100 (Good)
Failure Rate         2.3%
Slow Job Rate        5.1%

Overview:
  Total Jobs         1,234
  Completed          1,195
  Failed             28
  Processing         8
  Pending            3

Performance:
  Avg Execution Time 1.8s
  Max Execution Time 45.2s
  Avg Memory Usage   4.2 MB
  Avg Queries        12

Top Failed Jobs:
┌──────────────────────────────┬──────────┐
│ Job                          │ Failures │
├──────────────────────────────┼──────────┤
│ App\Jobs\ProcessOrder        │ 12       │
│ App\Jobs\SendInvoiceEmail    │ 8        │
│ App\Jobs\GenerateReport      │ 5        │
└──────────────────────────────┴──────────┘

```

Features in Detail
------------------

[](#features-in-detail)

### 1. Real-Time Failure Notifications

[](#1-real-time-failure-notifications)

Get notified the moment a job fails:

```
// config/queue-watcher.php

'notifications' => [
    'enabled' => true,
    'channels' => [
        'slack' => env('QUEUE_WATCHER_SLACK_WEBHOOK'),
        'discord' => env('QUEUE_WATCHER_DISCORD_WEBHOOK'),
        'database' => true,
        'log' => true,
    ],

    'events' => [
        'job_failed' => true,
        'job_slow' => true,
        'job_stuck' => true,
    ],
],
```

### 2. Performance Tracking

[](#2-performance-tracking)

Automatically tracks:

- ⏱️ Execution time
- 💾 Memory usage
- 🔍 Query count
- 🔁 Retry attempts

Detects anomalies:

- Jobs taking 2x longer than average
- Unusual memory spikes
- Query count explosions (N+1 detection)

### 3. Job Replay

[](#3-job-replay)

Safely replay failed jobs:

```
use lstables\QueueWatcher\Services\JobReplay;

// Replay programmatically
$jobReplay = app(JobReplay::class);
$jobReplay->replayJob($watchedJob);

// Replay with confirmation
$jobReplay->replayJobs([123, 124, 125]);
```

Features:

- ✅ Original payload preserved
- ✅ Batch replay support
- ✅ Confirmation prompts
- ✅ Error handling

### 4. Dependency Tracking

[](#4-dependency-tracking)

Track job chains and batches:

```
// Jobs in a chain
Bus::chain([
    new ProcessOrder($order),
    new SendConfirmation($order),
    new UpdateInventory($order),
])->dispatch();

// Queue Watcher tracks the entire chain
// See which step failed
// Replay from the failed step
```

### 5. Smart Filtering

[](#5-smart-filtering)

Find exactly what you need:

```
# Failed jobs from today
php artisan queue:inspect --failed --recent=24

# Slow jobs (taking longer than threshold)
php artisan queue:inspect --slow

# Specific job class
php artisan queue:inspect --job="App\Jobs\ProcessOrder"

# Combine filters
php artisan queue:inspect --failed --slow --recent=12
```

### 6. JSON Output for Scripting

[](#6-json-output-for-scripting)

All commands support `--json`:

```
# Get JSON output
php artisan queue:stats --json

# Use in scripts
HEALTH=$(php artisan queue:stats --json | jq '.health.score')
if [ $HEALTH -lt 70 ]; then
  echo "Queue health is low!"
  php artisan queue:replay --all
fi
```

Configuration
-------------

[](#configuration)

```
// config/queue-watcher.php

return [
    // Enable/disable globally
    'enabled' => env('QUEUE_WATCHER_ENABLED', true),

    // Recording settings
    'recording' => [
        'record_all' => false,          // Record successful jobs
        'record_failed' => true,        // Always record failures
        'retention_days' => 30,         // Keep for 30 days
        'max_payload_size' => 1048576,  // 1MB limit

        // Mask sensitive data
        'mask_sensitive_keys' => [
            'password', 'token', 'secret', 'api_key', 'credit_card'
        ],
    ],

    // Performance monitoring
    'performance' => [
        'track_metrics' => [
            'execution_time' => true,
            'memory_usage' => true,
            'query_count' => true,
        ],

        // Alert if job is 2x slower than average
        'anomaly_threshold_percent' => 200,
    ],

    // Notifications
    'notifications' => [
        'slow_threshold' => 30, // seconds
        'events' => [
            'job_failed' => true,
            'job_slow' => true,
            'memory_spike' => true,
        ],
    ],
];
```

Use Cases
---------

[](#use-cases)

### Debugging Production Failures

[](#debugging-production-failures)

```
# Job failed in production, what happened?
php artisan queue:inspect --failed --recent=1

# Found job 543, inspect it
php artisan queue:inspect 543

# Compare with successful runs
php artisan queue:compare 543

# Looks like a data issue, fix the data and replay
php artisan queue:replay 543
```

### Monitoring Queue Health

[](#monitoring-queue-health)

```
# Add to cron (runs every hour)
0 * * * * php artisan queue:stats --json | your-monitoring-tool

# Get alerted when health drops
*/15 * * * * [ $(php artisan queue:stats --json | jq '.health.score') -lt 80 ] && send-alert
```

### Bulk Replay After Deployment

[](#bulk-replay-after-deployment)

```
# Deployed a fix, replay all failed jobs
php artisan queue:replay --all --limit=100

# Or replay just the affected job type
php artisan queue:replay --job="App\Jobs\ProcessOrder"
```

### Performance Optimization

[](#performance-optimization)

```
# Find slowest jobs
php artisan queue:inspect --slow

# Compare fast vs slow runs
php artisan queue:compare 789

# Check if it's an N+1 query issue
# (Look at query count in comparison)
```

Real-World Examples
-------------------

[](#real-world-examples)

### Example 1: Order Processing Job

[](#example-1-order-processing-job)

Your `ProcessOrder` job starts failing. Here's how to debug:

```
# See recent failures
php artisan queue:inspect --failed --job="App\Jobs\ProcessOrder"

# Inspect the first failure
php artisan queue:inspect 123

# Compare with successful orders
php artisan queue:compare 123
```

Output shows:

- ❌ Failed job had 47 queries (vs 12 normal)
- ❌ Execution time 5x higher
- ❌ Memory usage spiked

**Solution**: N+1 query problem. Add eager loading.

### Example 2: Email Sending Job

[](#example-2-email-sending-job)

Random failures sending emails:

```
php artisan queue:stats --hours=168
```

Output shows:

- 95% success rate
- Failures clustered around 2pm-3pm daily

**Solution**: Email provider rate limits during peak hours. Add rate limiting or spread jobs.

### Example 3: Report Generation

[](#example-3-report-generation)

Report generation times out:

```
php artisan queue:compare 456
```

Output shows:

- ✅ Successful reports: 2-3 seconds
- ❌ Failed report: Timed out at 30 seconds
- Payload difference: User requested 10x more data

**Solution**: Add pagination or increase timeout for large reports.

Comparison with Laravel Horizon
-------------------------------

[](#comparison-with-laravel-horizon)

FeatureQueue WatcherHorizonWorks with all queue drivers✅❌ Redis onlyJob replay✅❌Compare failed vs successful✅❌Performance metrics✅✅Real-time monitoring✅✅Failure analysis✅❌CLI commands✅LimitedDependency tracking✅✅CostFreeFree**Use both!** Horizon for its beautiful UI, Queue Watcher for debugging and analysis.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING](CONTRIBUTING.md).

Credits
-------

[](#credits)

- [Your Name](https://github.com/yourname)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md).

Support
-------

[](#support)

- 🐛 [Report bugs](https://github.com/yourname/laravel-queue-watcher/issues)
- 💡 [Request features](https://github.com/yourname/laravel-queue-watcher/issues)
- 📖 [Read the docs](https://github.com/yourname/laravel-queue-watcher)

Roadmap
-------

[](#roadmap)

- Web dashboard (v2.0)
- Slack/Discord notifications
- Job dependency graph visualization
- Historical trending
- Custom alerting rules
- Integration with monitoring tools (Sentry, Bugsnag)
- Job performance profiling
- Automatic replay strategies

---

**Built with ❤️ for the Laravel community**

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance76

Regular maintenance activity

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

129d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2775675a2575f636baf76ce3ad2d538ef951b51487744ec434c163edc57d31c4?d=identicon)[lstables](/maintainers/lstables)

---

Tags

laravelmonitoringdebuggingqueuejobsfailed jobs

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lstables-laravel-queue-watcher/health.svg)

```
[![Health](https://phpackages.com/badges/lstables-laravel-queue-watcher/health.svg)](https://phpackages.com/packages/lstables-laravel-queue-watcher)
```

###  Alternatives

[kssadi/log-tracker

A powerful, intuitive, and efficient log viewer for Laravel applications.

264.8k](/packages/kssadi-log-tracker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
