PHPackages                             aduzenko/laravel-configurable-prometheus - 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. aduzenko/laravel-configurable-prometheus

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

aduzenko/laravel-configurable-prometheus
========================================

A package providing configurable interface to export Prometheus metrics in Laravel

v1.0.1(11mo ago)137MITPHPPHP ^8.3CI passing

Since May 3Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/anatolyduzenko/laravel-configurable-prometheus)[ Packagist](https://packagist.org/packages/aduzenko/laravel-configurable-prometheus)[ RSS](/packages/aduzenko-laravel-configurable-prometheus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (5)Used By (0)

Laravel Configurable Prometheus
===============================

[](#laravel-configurable-prometheus)

[![Run Tests](https://github.com/anatolyduzenko/laravel-configurable-prometheus/actions/workflows/run-tests.yml/badge.svg)](https://github.com/anatolyduzenko/laravel-configurable-prometheus/actions/workflows/run-tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/5080b7a1ce3d0d71317b5dd21528e1753496bf3fcd4b30318a7ba54e1d0618be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6164757a656e6b6f2f6c61726176656c2d636f6e666967757261626c652d70726f6d6574686575732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aduzenko/laravel-configurable-prometheus)[![License](https://camo.githubusercontent.com/8b0a6953607f14d5848cdb122831fe7f730bd262060dd06a3c035d7c5fb96177/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6164757a656e6b6f2f6c61726176656c2d636f6e666967757261626c652d70726f6d6574686575732e7376673f7374796c653d666c61742d737175617265)](LICENSE)

> A Laravel package for defining, managing, and exporting Prometheus metrics in a flexible, extensible way.

---

✨ Features
----------

[](#-features)

- Simple configuration-driven metric definitions
- Full support for **Counter**, **Gauge**, **Histogram**, and **Summary**
- Designed for **Laravel 12** and PHP 8.3+
- Define metrics in your app, not just in the package

---

🚀 Installation
--------------

[](#-installation)

```
composer require aduzenko/laravel-configurable-prometheus
```

---

⚙️ Publishing config
--------------------

[](#️-publishing-config)

```
php artisan vendor:publish --tag=prometheus-config
```

This will publish:

- `config/prometheus.php`
- example metrics route

---

### 🔐 Authentication for report route

[](#-authentication-for-report-route)

The Prometheus endpoint is protected from unauthorized access by basic HTTP authentication.

#### Step 1: Add credentials to your `.env` file

[](#step-1-add-credentials-to-your-env-file)

```
PROMETHEUS_USER=prom
PROMETHEUS_PASSWORD=secret
```

---

### 📡 Route setup for Prometheus metrics

[](#-route-setup-for-prometheus-metrics)

The Prometheus endpoint is configurable.

#### Update route in `config/prometheus.php` file

[](#update-route-in-configprometheusphp-file)

```
'endpoint' => 'prometheus',
```

---

🧩 Defining custom metrics
-------------------------

[](#-defining-custom-metrics)

Define a class implementing `MetricGroup`:

```
namespace App\Metrics;

use AnatolyDuzenko\ConfigurablePrometheus\DTO\MetricDefinition;
use AnatolyDuzenko\ConfigurablePrometheus\Enums\MetricType;
use AnatolyDuzenko\ConfigurablePrometheus\Contracts\MetricGroup;

class ApiMetrics implements MetricGroup
{
    public function definitions(): array
    {
        return [
            new MetricDefinition(
                namespace: 'api',
                name: 'response_time_seconds',
                helpText: 'API response time',
                type: MetricType::Histogram,
                labelNames: ['route'],
                buckets: [0.1, 0.3, 0.5, 1, 2, 5]
            )
        ];
    }
}
```

Then reference your group in `config/prometheus.php`:

```
'groups' => [
    \App\Metrics\ApiMetrics::class,
],
```

---

📈 Usage
-------

[](#-usage)

```
// In your class constructor, use
public function __construct(protected MetricManager $metrics)
    {}
// then
$this->metrics->inc('users', 'user_logins_total', ['web']);
$this->metrics->set('users', 'active_users', 42, ['web']);
$this->metrics->observe('api', 'response_time_seconds', 0.32, ['/api/v1']);
```

### Alternate usage

[](#alternate-usage)

```
// In your method
public function index(Request $request, MetricManager $metrics)
{
    // ....
    $metrics->inc('users', 'user_logins_total', ['web']);
    $metrics->set('users', 'active_users', 42, ['web']);
    $metrics->observe('api', 'response_time_seconds', 0.32, ['/api/v1']);
}
```

---

🧪 Testing
---------

[](#-testing)

```
vendor/bin/phpunit
```

---

📄 License
---------

[](#-license)

MIT © Anatoly Duzenko

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance50

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Total

2

Last Release

355d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/023cf1a4ce55035205051b36f0d38bd6fdd84a3bb17bb15064ac7d8e454afd06?d=identicon)[aduzenko](/maintainers/aduzenko)

---

Top Contributors

[![anatolyduzenko](https://avatars.githubusercontent.com/u/8387069?v=4)](https://github.com/anatolyduzenko "anatolyduzenko (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aduzenko-laravel-configurable-prometheus/health.svg)

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

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[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)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[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)
