PHPackages                             faktly/laravel-prometheus-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. faktly/laravel-prometheus-metrics

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

faktly/laravel-prometheus-metrics
=================================

Comprehensive Prometheus metrics exporter for Laravel with optional support for Event Sourcing, Horizon, Meilisearch, Spatie Permission, and more.

v0.1.1(2mo ago)3166—0%MITPHPPHP ^8.4 || ^8.5CI passing

Since Dec 30Pushed 2mo agoCompare

[ Source](https://github.com/Faktly-GmbH/laravel-prometheus-metrics)[ Packagist](https://packagist.org/packages/faktly/laravel-prometheus-metrics)[ RSS](/packages/faktly-laravel-prometheus-metrics/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (10)Versions (4)Used By (0)

Laravel Prometheus Metrics
==========================

[](#laravel-prometheus-metrics)

[![Tests](https://github.com/Faktly-GmbH/laravel-prometheus-metrics/workflows/Tests/badge.svg)](https://github.com/Faktly-GmbH/laravel-prometheus-metrics/actions?query=workflow:Tests)[![Publish Release](https://github.com/Faktly-GmbH/laravel-prometheus-metrics/workflows/Publish%20Release/badge.svg)](https://github.com/Faktly-GmbH/laravel-prometheus-metrics/releases)[![PHP requirement](https://camo.githubusercontent.com/972b4a0b9b897b611a1edb6b71f99b7cabbd648e0a0888aa88237007c3e4ccb8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f66616b746c792f6c61726176656c2d70726f6d6574686575732d6d6574726963732f706870)](https://camo.githubusercontent.com/972b4a0b9b897b611a1edb6b71f99b7cabbd648e0a0888aa88237007c3e4ccb8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f66616b746c792f6c61726176656c2d70726f6d6574686575732d6d6574726963732f706870)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Contributors](https://camo.githubusercontent.com/8c66bcfd1d9e7486251bb43ecc61468d551b0df00ea05b8b08e07f5882332a3c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f46616b746c792d476d62482f6c61726176656c2d70726f6d6574686575732d6d657472696373)](https://github.com/Faktly-GmbH/laravel-prometheus-metrics/graphs/contributors)[![Latest Version on Packagist](https://camo.githubusercontent.com/6dcca45b8bc34263295272c305339c8cc53aad92c7c2504b63baed16fc1eebd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66616b746c792f6c61726176656c2d70726f6d6574686575732d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/faktly/laravel-prometheus-metrics)[![Downloads](https://camo.githubusercontent.com/f1e9468196d9ad7f29408012b6692eb22a878040fbc7aa2cb9e65a418b4b35eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66616b746c792f6c61726176656c2d70726f6d6574686575732d6d657472696373)](https://packagist.org/packages/faktly/laravel-prometheus-metrics)

---

**Stop guessing. Start measuring.** Expose production-grade Laravel metrics as JSON/YAML/Prometheus so Prometheus, Grafana, and any monitoring stack can tell you what is really happening inside your app.

If you have ever asked, “Why is the API slow?” or “Are queue jobs backing up?” or “Did deploy X increase errors?”, this package helps you answer in minutes, not hours.

 [![Example Grafana dashboard based on Faktly Laravel Prometheus metrics](assets/screenshots/example-dashboard.png)](assets/screenshots/example-dashboard.png)

---

Why this exists
---------------

[](#why-this-exists)

Most Laravel apps only become “observable” after something breaks.

This exporter gives you fast visibility into the stuff that actually moves the needle:

- Performance bottlenecks.
- Queue pressure.
- Cache behavior.
- Error patterns.
- Auth and session activity.

---

What you get
------------

[](#what-you-get)

✨ **10+ Metric Collectors**: Database, Sessions, Queue, Mail, Cache, Users, Event Sourcing, Permissions, Horizon, Meilisearch.

🔌 **Fully optional**: Enable what you need, disable what you do not.

🚀 **High performance**: Built-in caching with configurable TTL.

🔒 **Secure by default**: Token-protected endpoint.

📦 **Modern stack**: Laravel 11+, PHP 8.4+.

📊 **JSON export**: Prometheus-friendly, Grafana-friendly, also easy to consume for custom tooling.

---

Quick Start
-----------

[](#quick-start)

### Installation

[](#installation)

```
composer require faktly/laravel-prometheus-metrics
php artisan vendor:publish --provider="Faktly\LaravelPrometheusMetrics\LaravelPrometheusMetricsServiceProvider"
```

#### Count user session with prometheus\_metrics\_user\_sessions table

[](#count-user-session-with-prometheus_metrics_user_sessions-table)

If you use non-database session drivers, “active sessions” can be hard to measure reliably.

This package includes a database table plus middleware, so you can still count user sessions regardless of your session driver.

If you use UUID or ULID primary keys, adjust the published migration before applying it.

### Configure

[](#configure)

```
PROMETHEUS_METRICS_TOKEN=your-secret-token-here
```

#### Configure Prometheus scrape config

[](#configure-prometheus-scrape-config)

Add this to `/etc/prometheus/prometheus.yml` :

```
- job_name: "laravel"
  scheme: https
  metrics_path: /internal/metrics
  http_headers:
    X-Metrics-Token:
      values: ["YOUR_TOKEN"]
  static_configs:
    - targets: ["YOUR_HOST:443"]

```

Replace YOUR\_TOKEN and YOUR\_HOST.

You can create a safe token with `openssl rand -hex 64` and **YOUR\_HOST** could be a local **IP:PORT** combination or your website **HOST:PORT**.

### Verify it works

[](#verify-it-works)

```
curl -H "X-Metrics-Token: your-secret-token-here" \
  http://localhost/internal/metrics
```

#### Register Middleware for HTTP metrics

[](#register-middleware-for-http-metrics)

In legacy apps or custom middleware setups, register the HTTP metrics middleware early (but after session start).

Add this to Kernel.php, or in newer Laravel versions bootstrap/app.php:

```
->withMiddleware(function (Middleware $middleware) {
    // Global HTTP Middleware - runs for every request
    $middleware->use([
        \Faktly\LaravelPrometheusMetrics\Http\Middleware\RecordHttpMetricsMiddleware::class,
        \Faktly\LaravelPrometheusMetrics\Http\Middleware\TrackPrometheusUserSession::class,
    ]);
     // Middleware Priority
    $middleware->priority([
        \Illuminate\Cookie\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Faktly\LaravelPrometheusMetrics\Http\Middleware\RecordHttpMetricsMiddleware::class,
        \Faktly\LaravelPrometheusMetrics\Http\Middleware\TrackPrometheusUserSession::class,
    ]);
```

### Test Locally

[](#test-locally)

```
php artisan prometheus:test-metrics
```

PHPUnit / pest
--------------

[](#phpunit--pest)

During tests you might want to disable the extension. Simply add `` to your phpunit.xml file.

What Gets Measured
------------------

[](#what-gets-measured)

CollectorMetricsOptionalRequires**Database**Active connections, queries✅Laravel DB**Sessions**Active count, driver info✅Laravel Sessions**Queue**Pending/failed jobs, per-queue✅Laravel Queue**Mail**Sent/failed count✅Laravel Mail**Cache**Driver info, hits/misses✅Laravel Cache**Users**Total count, active, per-role✅Laravel Auth**Event Sourcing**Events total, aggregates, per-type✅Spatie**Permissions**Roles, permissions, users per role✅Spatie**Horizon**Jobs per minute, processes✅Laravel**Meilisearch**Health, indexes, documents✅MeilisearchLicense
-------

[](#license)

MIT License. See [LICENSE.md](LICENSE.md) for details.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance86

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~12 days

Total

2

Last Release

70d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f350432a5f046e82f772c59f0cff1efd317f02648085d6b4390875e3c2085f1?d=identicon)[renepardon](/maintainers/renepardon)

---

Top Contributors

[![renepardon](https://avatars.githubusercontent.com/u/945323?v=4)](https://github.com/renepardon "renepardon (26 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2531.2M4](/packages/spatie-laravel-prometheus)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

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