Download the PHP package artprima/prometheus-metrics-bundle without Composer

On this page you can find all versions of the php package artprima/prometheus-metrics-bundle. 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-metrics-bundle

Master
Build Status
Coverage Status

Symfony 5/6/7 Prometheus Metrics Bundle

A Symfony bundle for the promphp/prometheus_client_php.

Installation

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

Configuration

config.yaml

Supported types are: Adapter name Prometheus class
in_memory Prometheus\Storage\InMemory
apcu Prometheus\Storage\APC
apcng Prometheus\Storage\APCng
redis Prometheus\Storage\Redis

routes.yaml

You can alternatively define your own path and rules:

Now your metrics are available to Prometheus using http:///metrics/prometheus.

Custom Metrics Collector

If you want to collect your own metrics, you should create a class that will implement one or several interfaces that are the children of the Artprima\PrometheusMetricsBundle\Metrics\MetricsCollectorInterface.

When using autoconfigure = true, by implementing Artprima\PrometheusMetricsBundle\Metrics\MetricsCollectorInterface Symfony will automatically configure your metrics collector to be used by the collector registry.

By implementing one of the following interfaces you can collect the metrics on one of the listed Symfony kernel events:

The following collectors will only work if you define enable_console_metrics: true in the bundle configuration:

For advanced usage you can implement Artprima\PrometheusMetricsBundle\Metrics\MetricsCollectorInterface directly.

There is also Artprima\PrometheusMetricsBundle\Metrics\MetricsCollectorInitTrait will add the init method to your collector.

If you don't use autoconfigure = true, then you will have to add this to your services.yaml:

Custom Storage Adapter Factory

A storage adapter is an instance of Prometheus\Storage\Adapter. To create your own storage adapter you should create a custom factory implementing Artprima\PrometheusMetricsBundle\StorageFactory\StorageFactoryInterface.

Symfony will automatically configure your storage factory with autoconfigure = true and implementing Artprima\PrometheusMetricsBundle\StorageFactory\StorageFactoryInterface. If you don't use autoconfigure = true, then you will have to add this to your services.yaml:

Default Metrics

These are default metrics exported by the application:

Note that, php_info comes from the underlying library promphp/prometheus_client_php. Other metrics are gathered by the built-in class Artprima\PrometheusMetricsBundle\Metrics. Here, in the example we have a prefix symfony and the metrics show a single request to the root named app_dummy_homepage. Symfony instance is named dev here. Instance name comes from the server var HOSTNAME ($request->server->get('HOSTNAME')) and defaults to dev.

Clear Metrics

The bundle provides a console command to clear metrics from the storage. Simply run:

Contributors

denisvmedia Johnmeurt rmbl InboxViktorV jb-reynaud luca-nardelli
denisvmedia Johnmeurt rmbl InboxViktorV jb-reynaud luca-nardelli
alshenetsky edditor marein ctrl-f5 ns3777k scrutinizer-auto-fixer
alshenetsky edditor marein ctrl-f5 ns3777k scrutinizer-auto-fixer
Yozhef karolmalinowski
Yozhef karolmalinowski

Code license

You are free to use the code in this repository under the terms of the MIT license. LICENSE contains a copy of this license.


All versions of prometheus-metrics-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
promphp/prometheus_client_php Version ^2.6
symfony/http-kernel Version ^5.4|^6.2|^7.0
symfony/dependency-injection Version ^5.4|^6.2|^7.0
symfony/config Version ^5.4|^6.2|^7.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 artprima/prometheus-metrics-bundle contains the following files

Loading the files please wait ....