Download the PHP package ensi/laravel-prometheus without Composer
On this page you can find all versions of the php package ensi/laravel-prometheus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-prometheus
Prometheus client for laravel
Adapter for promphp/prometheus_client_php
Installation
You can install the package via composer:
Publish the config with:
Version Compatibility
Laravel Prometheus | Laravel | PHP |
---|---|---|
^1.0.0 | ^9.x | ^8.1 |
^1.0.4 | ^9.x || ^10.x | ^8.1 |
^1.0.9 | ^9.x || ^10.x || ^11.x | ^8.1 |
Basic Usage
Before you wind up the metric counters, you need to register them. The best thing to do is to use the boot() method from the application service provider.
Updating the counter value is just as easy
Configuration
The structure of the configuration file
Bag
You may want to have several sets of metrics, for example, one set with technical metrics, such as the number of http requests or unexpected exceptions, and a second set for business values, such as the number of orders or impressions of a particular page. To do this, the concept of bag is introduced. You can configure several bugs by specifying your own data warehouse for each, a separate endpoint for collecting metrics, etc.
Storage type
You can use all the storage (Adapters) from the promphp/prometheus_client_php package. In addition, you can specify the name of the redis connection from the file config/databases.php
.
Storage configuration options.
Store metrics in the process memory.
Use apcupsd
or an alternative APCuNG adapter
A Redis adapter that will create a phpredis connection by itself
Laravel Redis connection from config/databases.php
. The same Redis adapter will be created under the hood, but it will take the native phpredis connection object from laravel's Redismanager.
Advanced Usage
You can select another bag to create and update metrics in it using the bag($bagName)
method.
Label Middlewares
You can add a label to all bagmetrics by specifying the so-called Label middleware in its configuration. Label middleware is triggered at the moment the metric is determined and at the moment its counter is updated, adding in the first case to the label name, and in the second case the value.
For example, we have a TenantLabelProvider
We register it in the bag configuration.
Then, as usual, we work with metrics.
As a result, the metric will have not two, but three labels
On demand metrics
Sometimes metrics are not linked to application events. Usually these are metrics of the gauge type, which it makes no sense to update on each incoming request, because prometheus will still take only the last set value. Such metrics can be calculated at the time of collection of metrics by prometheus. To do this, you need to create a so-called on demand metric. This is the class in which you register metrics and set values in them.
The update of such metrics occurs at the moment prometheus addresses the endpoint of obtaining metrics.
Contributing
Please see CONTRIBUTING for details.
Testing
- composer install
- composer test
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-prometheus with dependencies
ext-redis Version *
laravel/framework Version ^9.0 || ^10.0 || ^11.0
promphp/prometheus_client_php Version ^2.6