PHPackages                             vntrungld/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. vntrungld/prometheus-exporter

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

vntrungld/prometheus-exporter
=============================

Prometheus Exporter for Laravel

v1.2.0(3mo ago)03.1k↓50%2MITPHPPHP ^7.4|^8.0|^8.1|^8.2|^8.3|^8.4CI passing

Since Aug 14Pushed 3mo ago1 watchersCompare

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

READMEChangelog (7)Dependencies (4)Versions (8)Used By (2)

Laravel Prometheus Exporter
===========================

[](#laravel-prometheus-exporter)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0ab935c28ad529b933da8f70d6b73035af50e909d14ef97921da6ac4f8708b08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766e7472756e676c642f70726f6d6574686575732d6578706f727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vntrungld/prometheus-exporter)[![Total Downloads](https://camo.githubusercontent.com/7cd7f68306974b7bc7af08de8f6d967ead2c97e0d84f5cb028d159dda24ccc10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766e7472756e676c642f70726f6d6574686575732d6578706f727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vntrungld/prometheus-exporter)[![Tests](https://github.com/vntrungld/prometheus-exporter/workflows/Tests/badge.svg)](https://github.com/vntrungld/prometheus-exporter/actions?query=workflow%3ATests)

A simple and extensible Prometheus metrics exporter for Laravel applications.

Requirements
------------

[](#requirements)

- PHP 7.4, 8.0, 8.1, 8.2, 8.3, or 8.4
- Laravel 6.x, 7.x, 8.x, 9.x, 10.x, 11.x, or 12.x

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

[](#installation)

Install via Composer:

```
composer require vntrungld/prometheus-exporter
```

Publish the configuration file:

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

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

[](#configuration)

The configuration file will be published to `config/prometheus-exporter.php`:

```
return [
    // Enable or disable the exporter
    'enabled' => env('PROMETHEUS_EXPORTER_ENABLED', true),

    // Metric namespace prefix
    'namespace' => env('PROMETHEUS_EXPORTER_NAMESPACE', 'laravel'),

    // Endpoint path (e.g., /metrics)
    'path' => env('PROMETHEUS_EXPORTER_PATH', 'metrics'),

    // Optional security token
    'token' => env('PROMETHEUS_EXPORTER_TOKEN'),

    // Middleware for the metrics endpoint
    'middleware' => [
        \Vntrungld\PrometheusExporter\Middlewares\Authorize::class,
    ],

    // Tier-based collector configuration (useful for K8s deployments)
    'tier' => env('PROMETHEUS_EXPORTER_TIER', 'default'),

    'tiers' => [
        'default' => [
            'collectors' => [
                \Vntrungld\PrometheusExporter\Collectors\TestCollector::class,
            ],
            'sets' => [],
        ],
    ],
];
```

Usage
-----

[](#usage)

### Accessing Metrics

[](#accessing-metrics)

Once installed, metrics are available at the configured endpoint:

```
GET /metrics

```

If you've configured a security token:

```
GET /metrics?token=your-token

```

### Creating Custom Collectors

[](#creating-custom-collectors)

Create a collector by implementing the `Collector` interface:

```
