PHPackages                             hans-thomas/laravel-prometheus-exporter - 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. hans-thomas/laravel-prometheus-exporter

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

hans-thomas/laravel-prometheus-exporter
=======================================

A laravel service provider to export metrics for prometheus.

v2.3.1(5y ago)0124MITPHPPHP &gt;=7.4

Since Jul 28Pushed 5y agoCompare

[ Source](https://github.com/Hans-Thomas/LaravelPrometheusExporter)[ Packagist](https://packagist.org/packages/hans-thomas/laravel-prometheus-exporter)[ RSS](/packages/hans-thomas-laravel-prometheus-exporter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (8)Versions (30)Used By (0)

LaravelPrometheusExporter
=========================

[](#laravelprometheusexporter)

A laravel and lumen service provider to export metrics for prometheus.

Supported laravel versions
--------------------------

[](#supported-laravel-versions)

Laravel 7.x

Main features
-------------

[](#main-features)

- Metrics with APC
- Metrics with Redis
- Metrics with InMemory
- Metrics with the push gateway
- Request per route middleware (total and duration metrics)

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

[](#installation)

### Composer

[](#composer)

> composer require hans-thomas/laravel-prometheus-exporter

### Application

[](#application)

Once installed you can now publish your config file and set your correct configuration for using the package.

```
php artisan vendor:publish --provider="Hasn\PrometheusExporter\Provider\PrometheusExporterServiceProvider" --tag="config"
```

This will create a file `config/prometheus-exporter.php`.

Configuration
-------------

[](#configuration)

KeyEnvValueDescriptionDefaultadapterPROMETHEUS\_ADAPTERSTRINGapc, redis, inmemory or pushapcnamespace---STRINGdefault: appappnamespace\_http---STRINGnamespace for "RequestPerRoute-Middleware metrics"httpredis.hostPROMETHEUS\_REDIS\_HOST, REDIS\_HOSTSTRINGredis host127.0.0.1redis.portPROMETHEUS\_REDIS\_PORT, REDIS\_PORTINTEGERredis port6379redis.passwordPROMETHEUS\_REDIS\_PASSWORD, REDIS\_PASSWORDSTRINGredis passwordnullredis.timeout---FLOATredis timeout0.1redis.read\_timeout---INTEGERredis read timeout10push\_gateway.addressPROMETHEUS\_PUSH\_GATEWAY\_ADDRESSSTRINGpush gateway addresslocalhost:9091buckets\_per\_route---STRINGhistogram buckets for "RequestPerRoute-Middleware"---### buckets\_per\_route

[](#buckets_per_route)

```
'buckets_per_route' => [
    ROUTE-NAME => [10,20,50,100,200],
    ...
]

```

Usage
-----

[](#usage)

### Get metrics

[](#get-metrics)

#### Laravel

[](#laravel)

When you are using laravel you can use the default http endpoint:

> hans/pe/metrics

Of course you can also register your own route. Here is an example:

```
Route::get(
    ROUTE,
    [ \Hans\PrometheusExporter\Controller\LaravelController::class, 'metrics']
);

```

### Middleware

[](#middleware)

#### RequestPerRoute

[](#requestperroute)

A middleware to build metrics for "request\_total" and "requests\_latency\_milliseconds" per route.

##### Alias

[](#alias)

> lpe.requestPerRoute

##### Metrics

[](#metrics)

1. requests\_total (inc)
2. requests\_latency\_milliseconds (histogram)

##### Example

[](#example)

```
$router->get('/test/route', function () {
    return 'valid';
})->middleware('lpe.requestPerRoute');
```

> app\_requests\_latency\_milliseconds\_bucket{route="/test/route",method="GET",status\_code="200",le="0.005"} 0 ... app\_requests\_latency\_milliseconds\_count{route="/test/route",method="GET",status\_code="200"} 1 app\_requests\_latency\_milliseconds\_sum{route="/test/route",method="GET",status\_code="200"} 6 app\_requests\_total{route="/test/route",method="GET",status\_code="200"} 1

Roadmap
-------

[](#roadmap)

- histogram buckets per route (RequestPerRoute)

Reporting Issues
----------------

[](#reporting-issues)

If you do find an issue, please feel free to report it with GitHub's bug tracker for this project.

Alternatively, fork the project and make a pull request. :)

Testing
-------

[](#testing)

1. docker-compose up
2. docker exec fpm ./vendor/phpunit/phpunit/phpunit

Contributing
------------

[](#contributing)

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

Other
-----

[](#other)

### License

[](#license)

The code for LaravelPrometheusExporter is distributed under the terms of the MIT license (see [LICENSE](LICENSE)).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 61.3% of commits — single point of failure

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 ~45 days

Recently: every ~2 days

Total

29

Last Release

1942d ago

Major Versions

v1.9.0 → v2.02021-01-09

PHP version history (4 changes)v1.0.0PHP &gt;=7.0

v1.3.0PHP &gt;=7.1

v1.8.0PHP &gt;=7.2

v2.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39920372?v=4)[Mohammad Mortazavi](/maintainers/hans-thomas)[@hans-thomas](https://github.com/hans-thomas)

---

Top Contributors

[![triadev](https://avatars.githubusercontent.com/u/10552858?v=4)](https://github.com/triadev "triadev (19 commits)")[![hans-thomas](https://avatars.githubusercontent.com/u/39920372?v=4)](https://github.com/hans-thomas "hans-thomas (10 commits)")[![martianoff](https://avatars.githubusercontent.com/u/7222812?v=4)](https://github.com/martianoff "martianoff (1 commits)")[![MyIgel](https://avatars.githubusercontent.com/u/1448057?v=4)](https://github.com/MyIgel "MyIgel (1 commits)")

---

Tags

laravelMetricsprometheus

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/hans-thomas-laravel-prometheus-exporter/health.svg)

```
[![Health](https://phpackages.com/badges/hans-thomas-laravel-prometheus-exporter/health.svg)](https://phpackages.com/packages/hans-thomas-laravel-prometheus-exporter)
```

###  Alternatives

[lkaemmerling/laravel-horizon-prometheus-exporter

A small package to gain and export long time information from Laravel &amp; Horizon for Prometheus.

1602.0M](/packages/lkaemmerling-laravel-horizon-prometheus-exporter)[triadev/laravel-prometheus-exporter

A laravel and lumen service provider to export metrics for prometheus.

2728.2k1](/packages/triadev-laravel-prometheus-exporter)

PHPackages © 2026

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