Download the PHP package flownative/prometheus without Composer

On this page you can find all versions of the php package flownative/prometheus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package prometheus

MIT license Packagist Maintenance level: Love

Prometheus client library for Neos Flow / PHP

This Flow package allows you to collect and provide metrics to Prometheus. It supports client-side aggregation of metrics data and provides an endpoint for Prometheus for scraping these metrics.

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

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](https://github.com/flownative/flow-prometheus/blob/0/README.md , if you are using an earlier version of this plugin).

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:

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:

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:

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:

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.

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:

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):

Usage

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

A simple counter:

A counter using labels:

A gauge:

Setting for each metric:

Manual usage of the Collector Registry, using the InMemoryStorage:

``

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.


All versions of prometheus with dependencies

PHP Build Version
Package Version
Requires neos/flow Version 7.* || 8.* || @dev
php Version ^7.4 || ^8.0
ext-zlib Version *
predis/predis Version ^1.1 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flownative/prometheus contains the following files

Loading the files please wait ....