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

ActiveLaravel-package

shureban/laravel-prometheus
===========================

Laravel SDK for working with prometheus metrics

1.2.0(3y ago)22.0k2MITPHPPHP ^8.1

Since Oct 11Pushed 3y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Laravel prometheus metrics
==========================

[](#laravel-prometheus-metrics)

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

[](#installation)

Require this package with composer using the following command:

```
composer require shureban/laravel-prometheus
```

Add the following class to the `providers` array in `config/app.php`:

```
Shureban\LaravelPrometheus\PrometheusServiceProvider::class,
```

You can also publish the config file to change implementations (ie. interface to specific class).

```
php artisan vendor:publish --provider="Shureban\LaravelPrometheus\PrometheusServiceProvider"
```

Update `.env` config, change REDIS\_CLIENT from redis to predis:

```
REDIS_CLIENT=predis

```

Creating metric class
---------------------

[](#creating-metric-class)

### CLI supporting

[](#cli-supporting)

You may create metrics via CLI commands

```
# Creating counter metric CustomCounterMetricName
php artisan make:counter CustomCounterMetricName --name={name} --labels={label_1,label_2,label_N} --description={description} --dynamic

# Creating gauge metric CustomGaugeMetricName
php artisan make:gauge CustomGaugeMetricName --name={name} --labels={label_1,label_2,label_N} --description={description} --dynamic
```

OptionAliasRequiredDescriptionnamefalseName of the metriclabelfalseThe metric labels list (comma separated)descriptionfalseThe metric descriptiondynamicdfalseThe metric description### Manual

[](#manual)

Create folder, where you will contain your custom metrics classes (for example `app/Prometheus`). Realise constructor with metric static params.

```
namespace App\Prometheus;

use Shureban\LaravelPrometheus\Counter;
use Shureban\LaravelPrometheus\Attributes\Name;
use Shureban\LaravelPrometheus\Attributes\Labels;

class AuthCounter extends Counter
{
    public function __construct()
    {
        $name   = new Name('auth');
        $labels = new Labels(['event']);
        $help   = 'Counter of auth events';

        parent::__construct($name, $labels, $help);
    }
}
```

Usages
------

[](#usages)

### General metrics flow

[](#general-metrics-flow)

Using DI (or not), increase the metric value.

```
use App\Prometheus\AuthCounter;

class RegisterController extends Controller
{
    public function __invoke(..., AuthCounter $counter): Response
    {
        // Registration new user logic

        $counter->withLabelsValues(['registration'])->inc();
    }
}
```

Or, if you have static list of events, you may realize following flow:

```
namespace App\Prometheus\Counters;

use Shureban\LaravelPrometheus\Counter;
use Shureban\LaravelPrometheus\Attributes\Name;
use Shureban\LaravelPrometheus\Attributes\Labels;

class AuthCounter extends Counter
{
    public function __construct()
    {
        //...
    }

    public function registration(): void
    {
        $this->withLabelsValues(['registration'])->inc();
    }
}
```

This way helps you encapsulate logic with labels, and the code seems pretty

```
use App\Prometheus\AuthCounter;

class RegisterController extends Controller
{
    public function __invoke(..., AuthCounter $counter): Response
    {
        // Registration new user logic

        $counter->registration();
    }
}
```

### Dynamic metrics flow

[](#dynamic-metrics-flow)

Dynamic flow may help you attach more labels with different sizes

```
use App\Prometheus\AuthCounter;
use Shureban\LaravelPrometheus\Attributes\Labels;

class RegisterController extends Controller
{
    public function __invoke(..., DynamicAuthCounter $counter): Response
    {
        // Registration new user logic

        $counter->withLabels(Labels::newFromArray(['event' => 'registration', 'country' => 'US']))->inc();
        $counter->withLabels(Labels::newFromArray(['event' => 'registration', 'country' => 'US', 'browser' => 'chrome']))->inc();
        $counter->withLabels(Labels::newFromCollection($user->only(['country', 'browser'])))->inc();
    }
}
```

Rendering
---------

[](#rendering)

Render metrics data in text format

### Using config

[](#using-config)

In `config/prometheus.php`, find `web_route` param and set preferred route path. Default is `/prometheus/metrics`.

### Manual

[](#manual-1)

For render metrics by route, you need to provide next code:

```
$renderer = new RenderTextFormat();

return response($renderer->render(), Response::HTTP_OK, ['Content-Type' => RenderTextFormat::MIME_TYPE]);
```

of using string type hinting

```
return response(new RenderTextFormat(), Response::HTTP_OK, ['Content-Type' => RenderTextFormat::MIME_TYPE]);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

3

Last Release

1280d ago

PHP version history (2 changes)1.0.0PHP ^7.4|^8.0

1.1.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/d6df85acf6d2ae745da6af44e0db9c97e64c528ef5b9b0276bad5c4ac7f3888a?d=identicon)[Shureban](/maintainers/Shureban)

---

Top Contributors

[![Shureban](https://avatars.githubusercontent.com/u/5560764?v=4)](https://github.com/Shureban "Shureban (41 commits)")

---

Tags

Metricscountergaugeprometheusgraphanashureban

### Embed Badge

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

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

###  Alternatives

[artprima/prometheus-metrics-bundle

Symfony 5/6/7/8 Prometheus Metrics Bundle

1723.7M3](/packages/artprima-prometheus-metrics-bundle)[renoki-co/octane-exporter

Export Laravel Octane metrics using this Prometheus exporter.

30128.9k](/packages/renoki-co-octane-exporter)[worldia/instrumentation-bundle

Symfony opentelemetry auto-instrumentation: requests, commands, messenger, doctrine.

2769.8k](/packages/worldia-instrumentation-bundle)[triadev/laravel-prometheus-exporter

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

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

Prometheus metrics exporter

1842.1k](/packages/prismamedia-metrics)[krenor/prometheus-client

A PHP Client for Prometheus

1020.9k](/packages/krenor-prometheus-client)

PHPackages © 2026

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