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 Prometheus Laravel Package

spatie/laravel-prometheus

Export Laravel app metrics to Prometheus via a /prometheus endpoint. Register custom gauges/counters with simple callbacks, use built-in queue and Horizon metrics, and optionally secure the endpoint. Ideal for scraping by Prometheus and charting in Grafana.

View on GitHub
Deep Wiki
Context7

title: Using Queue exporters weight: 3

Important: If you are using Laravel Horizon, you should use the Horizon exporters instead of these queue exporters. Horizon provides its own comprehensive queue monitoring and these two exporters should not be used together as they may conflict or provide duplicate metrics.

We can export key metrics from Laravel's built-in queue system to Prometheus. To enable this feature, uncomment this line in the app/Providers/PrometheusServiceProvider.php file.

$this->registerQueueCollectors(['default']);

This will register the following collectors for monitoring your Laravel queues:

  • queue_size: exports the total number of jobs in each queue
  • queue_pending_jobs: exports the number of pending jobs per queue
  • queue_delayed_jobs: exports the number of delayed jobs per queue (supported drivers)
  • queue_reserved_jobs: exports the number of reserved jobs per queue
  • queue_oldest_pending_job_age: exports the age of the oldest pending job in seconds (supported drivers)

Configuration

Basic Usage

Register collectors for the default connection and default queue:

$this->registerQueueCollectors(['default']);

Custom Connection

Monitor queues on a specific connection:

$this->registerQueueCollectors(['high', 'low'], 'redis');

Prometheus Metrics

All metrics include connection and queue labels for filtering and aggregation:

# HELP app_queue_size The total number of jobs in the queue
# TYPE app_queue_size gauge
app_queue_size{connection="redis",queue="high"} 45
app_queue_size{connection="redis",queue="low"} 12

# HELP app_queue_delayed_jobs The number of delayed jobs in the queue
# TYPE app_queue_delayed_jobs gauge
app_queue_delayed_jobs{connection="redis",queue="high"} 3
app_queue_delayed_jobs{connection="redis",queue="low"} 0

Individual Collectors

You can also register collectors individually with custom parameters in your PrometheusServiceProvider.

use Spatie\Prometheus\Collectors\Queue\QueueSizeCollector;
use Spatie\Prometheus\Collectors\Queue\QueueDelayedJobsCollector;

Prometheus::registerCollectorClasses([
    QueueSizeCollector::class,
    QueueDelayedJobsCollector::class,
], ['connection' => 'redis', 'queues' => ['critical', 'high', 'normal']]);
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport