vmorozov/laravel-prometheus
A Laravel package for integrating Prometheus metrics into your application. Expose metrics endpoints, track counters and gauges, and add observability to Laravel services with minimal setup. Ideal for exposing application and request metrics to Prometheus scrapers.
Verdict: Low technical risk, high ownership risk. The package is a thin Laravel integration layer over the PHP Prometheus client (promphp/prometheus_client_php — verify in composer.json), providing a service provider, config, facade, and a scrape route. That surface area is small enough to audit in an afternoon and to fork if necessary. The concern is not what it does; it is who maintains it.
Architecture fit. Laravel's request-per-process model means metrics cannot live in process memory between requests without losing data behind any load balancer. Any viable deployment requires a shared storage adapter (Redis) so that N app instances contribute to one consistent exposition. Confirm the package supports Redis as a first-class adapter and that increments use atomic Redis operations rather than read-modify-write. Confirm whether the auto-registered middleware counts every request (including health checks and the /metrics scrape itself) — self-scraping inflates counters and is a classic first-week bug.
Integration feasibility. High. MIT license, Composer install, package auto-discovery, vendor:publish for config. A competent Laravel engineer can have counters and a /metrics endpoint in a non-production environment within a day. The real work is naming conventions, label design, and Redis provisioning — not the package.
Technical risk.
/metrics typically must bypass auth, CSRF, and the metrics middleware itself. Route-level network restriction is mandatory; the default config may not do this for you.predis vs phpredis support, and whether the pinned Prometheus client version has known issues.Key questions for the maintainer or the spike.
Stack fit. Assumes Laravel 9–12, PHP 8.1+, a Redis instance already present or easily added, and a Prometheus-compatible backend (self-hosted Prometheus, Grafana Cloud, AWS Managed Prometheus, or an OTel collector with a Prometheus receiver). If you already run OpenTelemetry, prefer OTel's Prometheus exporter and treat this package as redundant — do not run two instrumentation paths.
Migration path. There are three realistic starting points:
spatie/laravel-prometheus): the facade APIs are similar but not identical. Migrate behind an internal wrapper, not call-site by call-site.Compatibility. Pin the exact version in composer.json (no ^ on a package with zero dependents). Verify PHP and Laravel constraints against your matrix before rollout. Confirm the storage adapter matches your Redis client extension; mixing predis and phpredis across services causes confusing behaviour.
Sequencing.
Metrics interface in your app that delegates to the facade. Every call site depends on your interface, not the vendor facade. This is the single highest-leverage decision — it makes the fork-and-replace scenario a one-file change./metrics at the ingress/security-group layer, exclude it from the metrics middleware, set a Redis timeout and fail-open behaviour, add a Redis-down alert.Maintenance. Ownership transfers to your team on day one. Budget roughly 2–4 engineer-days per year for dependency bumps and fork maintenance, plus whatever you spend on the fork if upstream goes quiet. Mitigate by keeping the integration thin (see the wrapper above) so replacing it with promphp/prometheus_client_php directly — or OTel — is a contained effort. Track the upstream repo in your dependency register with a named owner and a review date.
Support. No vendor, no community, no published security policy, no CVE feed. Your security team will need to accept an unsupported dependency. Given the package is a few hundred lines of glue over a well-known client, that is defensible with a fork-ready posture; it would not be defensible for something on the auth path.
Scaling. Two axes:
prometheus_tsdb_head_series against a budget.Also plan for Redis key growth — histogram buckets and per-label series accumulate. Confirm whether the client sets TTLs or whether you need a sweep job.
Failure modes to design for.
| Failure | Effect | Mitigation |
|---|---|---|
| Redis unavailable | Request exceptions if not handled | Fail-open wrapper, 50ms timeout, alert on dropped metrics |
| Cardinality explosion | Prometheus scrape timeouts / OOM | Label allowlist, series budget alert |
/metrics publicly reachable |
Internal topology and traffic disclosure | Ingress restriction, separate internal port/route |
| Scrape route counted as traffic | Skewed request metrics | Exclude route from middleware |
| Multi-instance local storage | Metrics appear to reset randomly | Redis adapter enforced in config for all envs |
| Upstream abandonment | No fixes for new Laravel/PHP | Thin wrapper, MIT fork on standby |
Ramp-up. A Laravel developer is productive with the package in half a day. The binding constraint is Prometheus literacy — histogram vs. summary, quantiles, label design, and how to write a useful alert — which is a 2–3 day learning curve for one engineer who then becomes the internal owner. Plan a single named owner rather than distributed, casual usage; a shared metrics namespace with no owner reliably rots into an unqueried dashboard within two quarters.
How can I help you explore Laravel packages today?