PHPackages                             ensi/laravel-metrics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. ensi/laravel-metrics

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

ensi/laravel-metrics
====================

laravel metrics

1.0.20(2mo ago)265.9k↓18.8%1[1 PRs](https://github.com/ensi-platform/laravel-metrics/pulls)MITPHPPHP ^8.1CI passing

Since Dec 10Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ensi-platform/laravel-metrics)[ Packagist](https://packagist.org/packages/ensi/laravel-metrics)[ RSS](/packages/ensi-laravel-metrics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (30)Used By (0)

General prometheus metrics for laravel
======================================

[](#general-prometheus-metrics-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fc165cf8bf82013d49e8672331ca87e27111324ce5f056b7febec1da680a4d47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656e73692f6c61726176656c2d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ensi/laravel-metrics)[![Tests](https://github.com/ensi-platform/laravel-metrics/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/ensi-platform/laravel-metrics/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/5e77db5f5625bbcd07c448414cc24efea63ec1a14e8b8b7084ddfd7848711ced/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656e73692f6c61726176656c2d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ensi/laravel-metrics)

The package adds general-purpose metrics for a laravel web application. It is an addition to[ensi/laravel-prometheus](https://github.com/ensi-platform/laravel-prometheus)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ensi/laravel-metrics
```

Publish the config with:

```
php artisan vendor:publish --provider="Ensi\LaravelMetrics\MetricsServiceProvider"
```

Basic Usage
-----------

[](#basic-usage)

Add Http Middleware

```
# app/Http/Kernel.php

protected $middleware = [
    // ... other middlewares
    \Ensi\LaravelMetrics\HttpMiddleware\HttpMetricsMiddleware::class,
];
```

Add Guzzle Middleware to your http clients

```
$handlerStack = HandlerStack::create();

// Basic usage - only collects host-level metrics
$handlerStack->push(GuzzleMiddleware::middleware());

// With detailed path-level metrics
$handlerStack->push(GuzzleMiddleware::middleware('http_client', true, false));

// With histogram statistics
$handlerStack->push(GuzzleMiddleware::middleware('http_client', false, true));

// With both path metrics and statistics
$handlerStack->push(GuzzleMiddleware::middleware('http_client', true, true));

$client = new Client(['handler' => $handlerStack]);
$response1 = $client->get('http://httpbin.org/get');
```

The `middleware()` method accepts three parameters:

- `$type` (string, default: 'http\_client'): Metric type identifier
- `$collectPathMetrics` (bool, default: false): Enable per-path metrics collection (http\_client\_path\_\*)
- `$collectPathStats` (bool, default: false): Enable detailed statistics collection (http\_client\_path\_stats)

Configuration
=============

[](#configuration)

The structure of the configuration file

```
return [
    'ignore_commands' => [
        'kafka:consume',
    ],
    'ignore_routes' => [
        'prometheus.*'
    ],
    'http_requests_stats_groups' => [
        '' => [
            // If your app runs in multiple containers and each of them is responsible for its own metrics,
            // then you don't need to use the "summary"
            'type' => 'summary',
            'route_names' => ['*'], // or use prefix, like ['catalog.*', 'profile.favorites'],
            'time_window' => 30,
            'quantiles' => [0.5, 0.75, ,0.95],
        ],
        '' => [
            'type' => 'histogram',
            'route_names' => ['*'], // or use prefix, like ['catalog.*', 'profile.favorites'],
            'buckets' => [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
        ],
    ],
    'http_client_path_stats_buckets' => [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
    'watch_queues' => [
        'default',
    ],
];
```

**ignore\_routes** - a list of names of routes for which you do not need to track the processing time of http requests.
**ignore\_commands** - a list of team names for which you do not need to track metrics.
**http\_requests\_stats\_groups** - a list of histograms and percentiles. Each stats group has a list of the names of the routes that it tracks.
Thus, you can count statistics not for the entire application, but for individual groups of endpoints.
**http\_client\_path\_stats\_buckets** - bucket configuration for the http\_client\_path\_stats histogram metric used when collecting detailed statistics for HTTP client requests.

Metrics
-------

[](#metrics)

The names of the metrics are presented without the namespace.

NameTypeLabelsDescriptionhttp\_requests\_totalCountercode, endpointCounter of incoming http requestshttp\_request\_duration\_secondsCountercode, type, endpointTime counter for processing incoming http requestshttp\_stats\_&lt;name&gt;Histogram or SummaryStatistics on request processing time for the endpoint group specified in the confighttp\_client\_requests\_totalCounterhostCounter of outgoing HTTP client requestshttp\_client\_seconds\_totalCounterhostTime counter for outgoing HTTP client requestshttp\_client\_path\_requests\_totalCounterhost, pathCounter of outgoing HTTP client requests per pathhttp\_client\_path\_seconds\_totalCounterhost, pathTime counter for outgoing HTTP client requests per pathhttp\_client\_path\_statsHistogramhost, pathStatistics on outgoing HTTP client request processing timelog\_messages\_countCounterlevel, endpointNumber of messages in the logqueue\_job\_dispatched\_totalCounterconnection, queue, jobThe number of jobs sent to the queuequeue\_job\_runs\_totalCounterconnection, queue, jobThe number of processed jobs in the queuequeue\_job\_run\_seconds\_totalCounterconnection, queue, jobTime counter for completing tasks in the queuecommand\_runs\_totalCountercommand, statusNumber of completed commandscommand\_run\_seconds\_totalCountercommand, statusCommand execution time counterworkers\_totalGaugeworkerNumber of swoole workersworkers\_idleGaugeworkerNumber of free swoole workersContributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

### Testing

[](#testing)

1. composer install
2. composer test

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance87

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~59 days

Recently: every ~129 days

Total

21

Last Release

62d ago

PHP version history (2 changes)1.0.0PHP &gt;=8.1

1.0.15PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8089373?v=4)[Наталия](/maintainers/MsNatali)[@MsNatali](https://github.com/MsNatali)

![](https://avatars.githubusercontent.com/u/7352966?v=4)[Andrey](/maintainers/dimionx)[@DimionX](https://github.com/DimionX)

---

Top Contributors

[![MsNatali](https://avatars.githubusercontent.com/u/8089373?v=4)](https://github.com/MsNatali "MsNatali (26 commits)")[![MadridianFox](https://avatars.githubusercontent.com/u/3392587?v=4)](https://github.com/MadridianFox "MadridianFox (22 commits)")[![valerialukinykh](https://avatars.githubusercontent.com/u/123940772?v=4)](https://github.com/valerialukinykh "valerialukinykh (7 commits)")[![imamberdievf](https://avatars.githubusercontent.com/u/79088728?v=4)](https://github.com/imamberdievf "imamberdievf (4 commits)")[![DimionX](https://avatars.githubusercontent.com/u/7352966?v=4)](https://github.com/DimionX "DimionX (3 commits)")[![gkarkavin](https://avatars.githubusercontent.com/u/119850859?v=4)](https://github.com/gkarkavin "gkarkavin (2 commits)")[![andrewm05](https://avatars.githubusercontent.com/u/73471450?v=4)](https://github.com/andrewm05 "andrewm05 (1 commits)")[![C0rTeZ13](https://avatars.githubusercontent.com/u/120840631?v=4)](https://github.com/C0rTeZ13 "C0rTeZ13 (1 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ensi-laravel-metrics/health.svg)

```
[![Health](https://phpackages.com/badges/ensi-laravel-metrics/health.svg)](https://phpackages.com/packages/ensi-laravel-metrics)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[larabug/larabug

Laravel 6.x/7.x/8.x/9.x/10.x/11.x/12.x/13.x bug notifier

299549.3k1](/packages/larabug-larabug)[open-telemetry/opentelemetry-auto-wordpress

OpenTelemetry auto-instrumentation for Wordpress

17166.0k](/packages/open-telemetry-opentelemetry-auto-wordpress)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
