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

shureban/laravel-prometheus

Laravel package to expose Prometheus metrics. Install via Composer, publish config, switch Redis client to Predis, and create Counter/Gauge metrics via artisan commands or custom classes. Use DI to increment metrics with label values in your controllers.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Observability Roadmap: Enables standardized metrics collection for Laravel applications, aligning with broader observability initiatives (e.g., SRE practices, incident response improvements).
  • Build vs. Buy: Buy—avoids reinventing Prometheus integration, reducing dev time and maintenance overhead. Justification: The package abstracts Prometheus client complexity while providing Laravel-specific tooling (e.g., CLI metric generation, Redis-backed storage).
  • Use Cases:
    • API Performance: Track HTTP request latency, error rates, and throughput (e.g., http_request_duration_seconds).
    • Business Metrics: Custom counters/gauges for user actions (e.g., auth_events_total, purchase_conversions).
    • Infrastructure Monitoring: Database query performance, queue job processing times, or cache hit ratios.
    • Cost Optimization: Identify underutilized routes or slow endpoints to right-size infrastructure.
  • Feature Prioritization:
    • Short-Term: Integrate core metrics (e.g., Laravel HTTP middleware, queue workers) to baseline performance.
    • Mid-Term: Add custom metrics for critical user journeys (e.g., checkout funnel) to tie metrics to business KPIs.
    • Long-Term: Extend to multi-region deployments with Prometheus Federation or Thanos for long-term storage.
  • Tech Debt Reduction: Replaces ad-hoc logging/metrics (e.g., Log::info()) with structured, queryable data, improving debugging and postmortems.

When to Consider This Package

  • Adopt If:
    • Your Laravel app requires real-time metrics for performance tuning, alerting, or capacity planning.
    • You’re using Prometheus (or planning to) as your monitoring backend and need a PHP SDK.
    • Your team lacks expertise in Prometheus client libraries (e.g., prometheus/client_php) and wants Laravel-specific abstractions.
    • You’re already using Redis in your stack (the package relies on Predis for metrics collection).
    • You need low-code metric creation (e.g., CLI generators for counters/gauges) to accelerate development.
  • Look Elsewhere If:
    • You’re not using Prometheus: Consider alternatives like Datadog, New Relic, or OpenTelemetry for vendor-specific observability.
    • Your app is low-traffic (e.g., <100 RPS) and metrics aren’t critical for decision-making.
    • You require distributed tracing (e.g., OpenTelemetry) alongside metrics—this package focuses solely on metrics.
    • Your stack doesn’t use Redis (the package is Redis-dependent; alternatives like in-memory storage would require customization).
    • You need advanced Prometheus features (e.g., histograms, custom collectors) not supported by this SDK (consider prometheus/client_php directly).
    • Your team prefers graph-based metrics (e.g., Dynatrace) over Prometheus’s time-series model.

How to Pitch It (Stakeholders)

For Executives: "This package lets us instrument our Laravel app with Prometheus metrics—think of it as adding a ‘dashboard mode’ for our backend. We’ll track everything from API response times to user actions (e.g., sign-ups, purchases) in real time, enabling data-driven decisions on performance, cost, and scaling. It’s like turning on ‘developer tools’ for our infrastructure, but for the whole business. The best part? It’s a drop-in solution that avoids custom engineering, saving time and reducing risk. We’ll start with core metrics (e.g., error rates, latency) and expand to business-critical events (e.g., checkout conversions) as needed. This aligns with our observability roadmap and will pay dividends in debugging, capacity planning, and SLO management."

For Engineering: *"This is a lightweight Laravel wrapper for Prometheus that handles the heavy lifting of metrics collection. Key benefits:

  • Reduces Boilerplate: No need to manually instantiate Prometheus clients; use Laravel’s DI or CLI to generate metrics classes.
  • Redis-Backed: Metrics are stored in Redis (which we already use), so no new infrastructure.
  • Flexible: Supports counters (e.g., event counts), gauges (e.g., active users), and dynamic labels (e.g., country=US).
  • Prometheus-Native: Outputs metrics in the standard Prometheus format, so it plays well with Grafana, Alertmanager, etc.
  • Low Risk: Minimal dependencies (just Predis), and the package is battle-tested with Laravel 8–10.

Use Case Example:

Problem: Our API’s /checkout endpoint is slow, but we’re guessing which part is the bottleneck. Solution: Instrument the endpoint with a checkout_latency_seconds histogram and a checkout_errors_total counter. Prometheus will expose these metrics, and we’ll visualize them in Grafana to identify regressions.

Next Steps:

  1. Pilot: Integrate into a non-critical Laravel service (e.g., a staging API) to validate setup and performance impact.
  2. Expand: Add custom metrics for top user journeys (e.g., login, payment processing).
  3. Alert: Configure Prometheus Alertmanager to notify on anomalies (e.g., error rate > 1%).
  4. Document: Create runbooks for common metrics queries (e.g., ‘How to debug a spike in http_5xx_errors’)."*
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony