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

ActiveNeos-package[Logging &amp; Monitoring](/categories/logging)

flownative/prometheus
=====================

Prometheus metrics for Neos Flow applications

v1.4.0(1mo ago)626.5k↓60.4%61MITPHPPHP ^7.4 || ^8.0CI passing

Since Nov 20Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/flownative/flow-prometheus)[ Packagist](https://packagist.org/packages/flownative/prometheus)[ GitHub Sponsors](https://github.com/kdambekalns)[ GitHub Sponsors](https://github.com/robertlemke)[ RSS](/packages/flownative-prometheus/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (8)Dependencies (8)Versions (19)Used By (1)

[![MIT license](https://camo.githubusercontent.com/4661abfe916186acde514558e7f040833cb63ba7098401a51ce339cbb2b4cf9e/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](http://opensource.org/licenses/MIT)[![Packagist](https://camo.githubusercontent.com/f36f393b16a16d17023a7b8a01bbcd543842cb847eaab3b89050e0a79573d8e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f776e61746976652f70726f6d6574686575732e737667)](https://packagist.org/packages/flownative/prometheus)[![Maintenance level: Love](https://camo.githubusercontent.com/b24fe73a7439225808a806c9f1032014adf4933b5774648c0174cf0de1d56401/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61696e74656e616e63652d2545322539392541312545322539392541312545322539392541312d6666363962342e737667)](https://www.flownative.com/en/products/open-source.html)

Prometheus client library for Neos Flow / PHP
=============================================

[](#prometheus-client-library-for-neos-flow--php)

This [Flow](https://flow.neos.io) package allows you to collect and provide metrics to [Prometheus](https://www.prometheus.io). It supports client-side aggregation of metrics data and provides an endpoint for Prometheus for scraping these metrics.

How does it work?
-----------------

[](#how-does-it-work)

Your Flow application can provide different kinds of metrics, for example the current number of registered users (a gauge), or the number of requests to your API (a counter). Metrics values are stored in a storage – currently only Redis is supported, and there's an in-memory storage for testing.

The metrics endpoint (by default http(s)://your-host/metrics) collects all current metric values from the storage and renders it in a format which can be read by Prometheus. Therefore, metrics are *not* collected or generated during a request to the metrics endpoint. Depending on how expensive it is to update a metric (think: number of incoming HTTP requests vs. books sold but returned throughout the last 15 years), the values may be updated on the fly (e.g. by registering a Flow HTTP Component) or through a helper process (a cron-job or long-running command-line process).

Compatibility
-------------

[](#compatibility)

The `flownative/prometheus` 0.\* version branch supports Flow 5.x and 6.x, while `flownative/prometheus` 1.\* supports Flow 7.0 and later. Please note that this README applies to 1.\*. \[Refer to the "0" branches' README\]( , if you are using an earlier version of this plugin).

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

[](#installation)

The Prometheus integration is installed as a regular Flow package via Composer. For your existing project, simply include `flownative/prometheus` into the dependencies of your Flow or Neos distribution:

```
$ composer require flownative/prometheus
```

### Storage

[](#storage)

By default, this plugin uses the `InMemoryStorage` for testing purposes. You will want to use the `RedisStorage` instead, so you don't loose all metrics values between requests. The `RedisStorage` contained in this package does *not* require a special PHP extension, as it is implemented in plain PHP.

In order to use the `RedisStorage`, create an `Objects.yaml` in your package's or Flow distribution's `Configuration` directory and add the following configuration:

```
Flownative\Prometheus\DefaultCollectorRegistry:
  arguments:
    1:
      object: Flownative\Prometheus\Storage\RedisStorage

Flownative\Prometheus\Storage\RedisStorage:
  arguments:
    1:
      value:
        hostname: '%env:MY_REDIS_HOST%'
        port: '%env:MY_REDIS_PORT%'
        password: '%env:MY_REDIS_PASSWORD%'
        database: 20
```

In this example, environment variables are used for passing access parameters to the `RedisStorage`. Test your setup by opening the path `/metrics` of your Flow instance in a browser. You should see the following comment:

```
# Flownative Prometheus Metrics Exporter: There are no collectors registered at the registry.

```

If your Redis server uses [ACL](https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/)-based authentication, additionally provide a username:

```
Flownative\Prometheus\Storage\RedisStorage:
  arguments:
    1:
      value:
        hostname: '%env:MY_REDIS_HOST%'
        port: '%env:MY_REDIS_PORT%'
        username: '%env:MY_REDIS_USERNAME%'
        password: '%env:MY_REDIS_PASSWORD%'
        database: 20
```

All Redis keys used by this package are prefixed, by default with "flownative\_prometheus". You can set a custom prefix through the `keyPrefix` option. If your desired prefix is very long or contains special characters, enable the `hashKeyPrefix` option, which replaces the prefix by its md5 hash:

```
Flownative\Prometheus\Storage\RedisStorage:
  arguments:
    1:
      value:
        hostname: '%env:MY_REDIS_HOST%'
        port: '%env:MY_REDIS_PORT%'
        password: '%env:MY_REDIS_PASSWORD%'
        database: 20
        keyPrefix: '%env:MY_REDIS_PREFIX%'
        hashKeyPrefix: true
```

The `RedisStorage` also supports Redis cluster setups with Sentinel servers. If you'd like to connect to a cluster and use Sentinels for autodiscovery, omit the hostname and password options and use the sentinel option instead:

```
Flownative\Prometheus\Storage\RedisStorage:
  arguments:
    1:
      value:
        password: '%env:MY_REDIS_PASSWORD%'
        database: 20
        sentinels:
          - 'tcp://10.101.213.145:26379'
          - 'tcp://10.101.213.146:26379'
          - 'tcp://10.101.213.147:26379'
        service: 'mymaster'
```

Instead of providing sentinels as an array you can also set them as a comma-separated string.

The `RedisStorage` can be configured to ignore connection errors. This may protect your application against fatal errors at times when Redis is not available. Of course, no metrics are stored while Redis connections fail.

```
Flownative\Prometheus\Storage\RedisStorage:
  arguments:
    1:
      value:
        hostname: '%env:MY_REDIS_HOST%'
        port: '%env:MY_REDIS_PORT%'
        password: '%env:MY_REDIS_PASSWORD%'
        database: 20
        ignoreConnectionErrors: true
```

### Telemetry Path

[](#telemetry-path)

The path, where metrics are provided for scraping, is "/metrics" by default. You can change this path by setting a respective option for the HTTP middleware in `Objects.yaml`:

```
Flownative\Prometheus\Http\MetricsExporterMiddleware:
  arguments:
    1:
      value:
        ## Path at which metrics are published for scraping
        telemetryPath: '/some-other-path'
```

### Security

[](#security)

By default, the telemetry endpoint is *not* active. It is active when the environment variable `FLOWNATIVE_PROMETHEUS_ENABLE` is set to "true" (ie. "true" is a string value!). You can achieve this by setting the variable in your webserver's virtual host configuration.

The idea behind enabling telemetry through such a variable is, that you configure your webserver to provide metrics through a different port than your actual website or application. This way its easy to hide metrics through firewall rules or by not providing access to that port through your load balancer.

While setting up the telemetry endpoint on a dedicated port, it is also possible to let it share the webserver's port.

The telemetry endpoint can also be protected by requiring clients to authenticate first with username and password. HTTP Basic Authentication is configured as follows (`Objects.yaml`):

```
Flownative\Prometheus\Http\MetricsExporterMiddleware:
  arguments:
    1:
      value:
        basicAuth:

          # If set to non-empty values, HTTP Basic Auth is enabled:
          username: 'my-username'
          password: 'my-password'

          # Optional:
          realm: 'Acme App Metrics'
```

Usage
-----

[](#usage)

The `DefaultCollectorRegistry` is pre-configured and can be injected via Dependency Injection:

```
    /**
     * @Flow\Inject
     * @var \Flownative\Prometheus\CollectorRegistry\DefaultCollectorRegistry
     */
    protected $collectorRegistry;
```

A simple counter:

```
    $this->collectorRegistry->getCounter('acme_myproject_controller_hits_total')
        ->inc();
```

A counter using labels:

```
    $this->collectorRegistry->getCounter('acme_myproject_controller_hits_total')
        ->inc(1, ['result' => 'success']);
    …
    $this->collectorRegistry->getCounter('acme_myproject_controller_hits_total')
        ->inc(1, ['result' => 'failed']);
```

A gauge:

```
    $this->collectorRegistry->getGauge('neos_flow_sessions')
        ->set(count($this->sessionManager->getActiveSessions()),
            [
                'state' => 'active'
            ]
        );
```

A histogram observes individual values (for example durations in seconds) and counts them into a set of configurable buckets, additionally tracking the sum and total number of observations:

```
    $this->collectorRegistry->getHistogram('acme_myproject_request_duration_seconds')
        ->observe($durationInSeconds, ['method' => 'GET']);
```

If no buckets are configured, the Prometheus default buckets (`0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10`) are used. A trailing `+Inf` bucket is always added implicitly, so it must not be configured explicitly. The label name `le` is reserved for histograms and cannot be used.

Setting for each metric:

```
Flownative:
  Prometheus:
    metrics:
      acme_myproject_controller_hits_total:
        type: counter
        help: 'metric description'
      acme_myproject_successful_login_total:
        type: counter
        help: 'metric description'
      acme_myproject_request_duration_seconds:
        type: histogram
        help: 'metric description'
        labels: ['method']
        buckets: [0.1, 0.5, 1, 2.5, 5, 10]
```

Manual usage of the Collector Registry, using the `InMemoryStorage`:

```
    $registry = new CollectorRegistry(new InMemoryStorage());
    $registry->register('flownative_prometheus_test_calls_total', Counter::TYPE, 'a test call counter', ['tests', 'counter']);

    $counter = $registry->getCounter('flownative_prometheus_test_calls_total');
    $counter->inc(5.5);

    $sampleCollections = $registry->collect();

    $renderer = new Renderer();
    echo ($renderer->render($sampleCollections));
```

Running the tests
-----------------

[](#running-the-tests)

All key features are backed by unit tests. Currently, you need Redis running in order to run them. Provide the necessary credentials via `REDIS_HOST`, `REDIS_PORT`, and `REDIS_PASSWORD` (see `Objects.yaml`contained in this package).

Apart from that, tests are run like any other unit test suite for Flow.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance90

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 69.2% 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 ~142 days

Recently: every ~404 days

Total

18

Last Release

46d ago

Major Versions

0.x-dev → v1.0.02021-02-26

PHP version history (4 changes)0.5.1PHP 7.3.\* || 7.4.\*

0.5.2PHP 7.2.\* || 7.3.\* || 7.4.\*

v1.0.0PHP 7.4.\*

v1.1.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/95582?v=4)[Robert Lemke](/maintainers/robertlemke)[@robertlemke](https://github.com/robertlemke)

![](https://avatars.githubusercontent.com/u/10280881?v=4)[Flownative](/maintainers/flownative)[@flownative](https://github.com/flownative)

---

Top Contributors

[![robertlemke](https://avatars.githubusercontent.com/u/95582?v=4)](https://github.com/robertlemke "robertlemke (45 commits)")[![kdambekalns](https://avatars.githubusercontent.com/u/95873?v=4)](https://github.com/kdambekalns "kdambekalns (16 commits)")[![JellyFishCode](https://avatars.githubusercontent.com/u/73017822?v=4)](https://github.com/JellyFishCode "JellyFishCode (1 commits)")[![kaystrobach](https://avatars.githubusercontent.com/u/1185776?v=4)](https://github.com/kaystrobach "kaystrobach (1 commits)")[![mficzel](https://avatars.githubusercontent.com/u/1309380?v=4)](https://github.com/mficzel "mficzel (1 commits)")[![vsiebert-vcg](https://avatars.githubusercontent.com/u/286356529?v=4)](https://github.com/vsiebert-vcg "vsiebert-vcg (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

28.0k175.2k9](/packages/bagisto-bagisto)[unopim/unopim

UnoPim Laravel PIM

10.8k2.5k](/packages/unopim-unopim)[lion/bundle

Lion-framework configuration and initialization package

132.4k5](/packages/lion-bundle)

PHPackages © 2026

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