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
Prometheus Metrics Bundle

Prometheus Metrics Bundle Laravel Package

artprima/prometheus-metrics-bundle

Symfony bundle integrating promphp/prometheus_client_php to expose Prometheus metrics for your app. Supports Symfony 5.4–8.x and PHP 8.2–8.5, with configurable metric namespace, ignored routes, and custom labels for HTTP/request metrics.

View on GitHub
Deep Wiki
Context7

Symfony 5/6/7/8 Prometheus Metrics Bundle

Frequently asked questions about Prometheus Metrics Bundle
Can I use this bundle directly in a Laravel app, or is it only for Symfony?
This bundle is designed for Symfony, so it requires a bridge or adapter layer to work in Laravel. You’ll need to manually translate Symfony’s kernel events (like `kernel.request`) into Laravel’s middleware or event system. Consider using a Symfony microkernel alongside Laravel or building custom middleware to dispatch metrics events.
What Laravel versions are compatible with this bundle?
The bundle supports PHP 8.2–8.5, which aligns with Laravel 10.x and 11.x. However, since it’s Symfony-focused, you’ll need to handle integration manually. Test thoroughly in your Laravel version to ensure event compatibility.
How do I ignore specific routes from metrics collection?
Configure the `ignored_routes` option in your Symfony bundle config (e.g., `artprima_prometheus_metrics.ignored_routes`). For Laravel, you’ll need to map these to Laravel route names or middleware exclusions, as the bundle doesn’t natively support Laravel’s routing system.
Does this bundle support custom metrics beyond HTTP requests?
Yes, the bundle allows custom metrics via collectors. For Laravel, you’ll need to extend the `MetricsCollectorInterface` or create middleware to inject Laravel-specific metrics (e.g., Eloquent queries, queue jobs) into the Prometheus client.
Can I store metrics in Redis instead of APCu?
The bundle supports Redis storage via `promphp/prometheus_client_php`. Configure it in your Symfony setup, but ensure your Laravel app also uses Redis (e.g., with `predis` or `php-redis`) for shared access. APCu is simpler but less scalable for distributed Laravel apps.
How do I add custom labels to HTTP metrics in Laravel?
Use the `custom_labels` config in Symfony’s bundle to define labels like `action`. For Laravel, you’ll need to attach these labels via middleware or event listeners that modify the Symfony `RequestEvent` or `ResponseEvent` before metrics are collected.
Will this bundle work with Laravel’s queue system (e.g., Horizon)?
Not natively, but you can extend it by creating a custom collector that listens to Laravel’s `job.processing` or `job.failed` events. Inject these metrics into the Prometheus client manually, similar to how you’d handle HTTP metrics.
Are there performance concerns with collecting metrics in production?
Metrics collection adds minimal overhead, but Redis storage may introduce latency. Benchmark your setup with tools like Blackfire or Xdebug. For high-traffic apps, consider in-memory storage (e.g., APCu) or batching metrics collection.
How do I visualize Laravel-specific metrics in Grafana?
Use existing Prometheus dashboards and adapt them for Laravel metrics (e.g., queue depth, API latency). Create custom Grafana panels for Laravel-specific collectors. The bundle’s metrics will appear in Prometheus as long as they’re properly labeled.
What alternatives exist for Prometheus metrics in Laravel?
Consider `spatie/laravel-prometheus` (Laravel-native) or `robmorgan/phpmetrics` (PHP-agnostic). These avoid Symfony dependencies and integrate directly with Laravel’s middleware/events. Evaluate based on your need for Symfony compatibility or pure Laravel simplicity.
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.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views