Download the PHP package iamfarhad/laravel-prometheus without Composer

On this page you can find all versions of the php package iamfarhad/laravel-prometheus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-prometheus

๐Ÿš€ Laravel Prometheus Metrics Package

Latest Version on Packagist Total Downloads PHP Version Laravel Version GitHub Tests

Enterprise-grade Prometheus metrics exporter for Laravel applications with comprehensive monitoring capabilities and industry-standard SLO tracking.

Built on the official PromPHP/prometheus_client_php library for maximum compatibility and performance.

โœจ Key Features

๐Ÿ“ฆ Installation

Publish Configuration

HTTP Middleware Setup

For HTTP request tracking, you need to register the middleware. Choose one of these simple options:

โœ… Option 1: Easy Helper (Recommended)

No more complex setup! Add this single line to your bootstrap/app.php:

Benefits:

โœ… Option 2: Manual Registration

โœ… Option 3: Automatic Registration (Experimental)

Enable automatic middleware registration in your .env:

Note: Automatic registration attempts to register middleware programmatically. If it doesn't work in your setup, use Options 1 or 2.

โšก Option 4: Route-Specific Registration (Performance Optimized)

For high-performance applications where you want to monitor only specific routes:

Route Groups:

Individual Routes:

Route Groups with Aliases:

Controller-Level Registration:

Conditional Route Monitoring:

Benefits of Route-Specific Registration:

Use Cases:

๐Ÿš€ Quick Start

Basic Usage

Controller Integration

๐Ÿ“Š Built-in Collectors

๐ŸŒ HTTP Request Collector

Automatically enabled - Tracks all HTTP requests with comprehensive metrics.

Metrics:

Industry-Standard Configuration:

Example Metrics:

๐Ÿ—„๏ธ Database Query Collector

Automatically enabled - Monitors database performance with operation-level granularity.

Metrics:

Supported Operations: select, insert, update, delete, create, drop, alter, truncate

Fine-Grained Configuration:

Example Metrics:

โšก Cache Operation Collector

Disabled by default - Monitors application cache operations (not internal storage).

โš ๏ธ Important: Disabled by default to prevent recursive counting of Prometheus's own Redis operations.

Metrics:

Operations: get, put, forget, flush
Results: hit, miss, success, failure

Intelligent Filtering:

Enable for Application Cache:

๐Ÿ”„ Queue Job Collectors

Basic Queue Collector

Automatically enabled - Tracks queue job processing and performance.

Metrics:

Status Values: completed, failed, exception, timeout

Enhanced Queue Collector

Advanced monitoring with comprehensive queue health metrics:

Additional Metrics:

Configuration:

๐ŸŽฏ Command Collector

Automatically enabled - Tracks Laravel Artisan command executions.

Metrics:

Status Values: success, error, invalid_usage, interrupted, unknown

Configuration:

Example Metrics:

๐ŸŒŠ Horizon Collector

Available when Laravel Horizon is installed - Comprehensive Horizon monitoring.

Metrics:

Enable:

Features:

๐Ÿšจ Error Collector

Disabled by default - Tracks application errors and exceptions.

Metrics:

๐Ÿ“ Additional Collectors

Event Collector

Filesystem Collector

Mail Collector

Enable any collector:

โš™๏ธ Configuration

Storage Backends

Choose your preferred storage backend:

Global Namespace

Set a global namespace to avoid metric name conflicts:

Results in metrics like: myapp_http_requests_total

Industry-Standard Defaults

The package comes with optimized industry-standard configurations:

๐Ÿ”’ Security

Protecting the Metrics Endpoint

The package automatically registers a /metrics endpoint with configurable security:

IP Address Restriction

Use the built-in AllowIps middleware:

Environment Configuration:

Features:

Authentication

Add authentication middleware:

Combined Security

For maximum security:

๐Ÿ”ง Advanced Usage

Custom Metrics with Summary Support

Middleware Integration

Create custom middleware for application-specific metrics:

๐Ÿ“ˆ Monitoring & Alerting

Prometheus Configuration

Add this scrape configuration to your prometheus.yml:

Essential Queries

SLO Monitoring

Database Performance

Queue Health

Grafana Dashboard

Create comprehensive dashboards with:

Panels:

Alerts:

๐Ÿงช Testing

Test Suite Coverage

The package includes comprehensive tests:

Testing Custom Metrics

๐Ÿš€ Performance Optimization

Best Practices

  1. Enable Only Needed Collectors

  2. Optimize Storage Backend

  3. Configure Appropriate Buckets

  4. Monitor Resource Usage

    • Each enabled collector adds minimal overhead (~0.1ms per request)
    • Summary metrics use more memory than histograms
    • High-cardinality labels increase storage requirements
  5. Choose the Right Middleware Strategy

Middleware Performance Guide

Choose your middleware registration strategy based on your application requirements:

Application Type Recommended Option Reasoning
Standard Web/API Helper Registration (Option 1) Easy setup, automatic checks, minimal overhead
High-Traffic API (1000+ RPS) Route-Specific (Option 4) Monitor only critical endpoints, reduce overhead
Microservices Route-Specific (Option 4) Focus on service-specific endpoints
Admin Dashboards Global Registration (Option 1/2) Monitor all admin actions
Public APIs Route-Specific (Option 4) Monitor API endpoints, skip static assets
Development/Testing Auto Registration (Option 3) Zero-config for quick testing

Performance Impact Comparison:

Real-World Example:

Memory Optimization

๐Ÿ”ง Troubleshooting

Common Issues

  1. Cache Collector Showing False Metrics

    • Solution: Cache collector is disabled by default to prevent counting Prometheus's own Redis operations
    • Enable only for application cache: Ensure you're using dedicated cache stores
  2. High Memory Usage

    • Use Redis storage instead of Memory
    • Reduce histogram bucket count
    • Optimize Summary quantiles and max age
  3. Metrics Not Appearing

    • Check collector configuration in config/prometheus.php
    • Verify storage backend connectivity
    • Check Laravel logs for errors
  4. Slow Response Times
    • Optimize histogram bucket configuration
    • Use Redis with proper connection pooling
    • Consider metric sampling for very high traffic

Debug Mode

Enable comprehensive debug logging to troubleshoot metrics collection:

Debug Output Examples:

Debug Features:

Production Note: Always disable debug mode in production to avoid log bloat.

Middleware Configuration

All available environment variables for easy configuration:

๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

Development Setup

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license.

๐ŸŒŸ Support

๐Ÿ† Credits


๐Ÿš€ Built with โค๏ธ for the Laravel community

Ready for enterprise-grade monitoring with industry-standard SLO tracking! โญ

๐ŸŽฏ Key Differentiators


All versions of laravel-prometheus with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/config Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/events Version ^10.0|^11.0|^12.0|^13.0
illuminate/filesystem Version ^10.0|^11.0|^12.0|^13.0
illuminate/log Version ^10.0|^11.0|^12.0|^13.0
illuminate/mail Version ^10.0|^11.0|^12.0|^13.0
illuminate/redis Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
promphp/prometheus_client_php Version ^2.14
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package iamfarhad/laravel-prometheus contains the following files

Loading the files please wait ...