Download the PHP package gorerider/laravel-prometheus-exporter without Composer
On this page you can find all versions of the php package gorerider/laravel-prometheus-exporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gorerider/laravel-prometheus-exporter
More information about gorerider/laravel-prometheus-exporter
Files in gorerider/laravel-prometheus-exporter
Package laravel-prometheus-exporter
Short Description A prometheus exporter for Laravel & Lumen
License MIT
Informations about the package laravel-prometheus-exporter
laravel-prometheus-exporter
Originally, this is a fork of traum-ferienwohnungen/laravel-prometheus-exporter with updated dependencies. Main goal of this work is to make the lib compatible with Laravel 7 and Lumen 7 running on PHP 7.4.
However, with the need to support guzzlehttp/guzzle 7
, dependency was replaced with PromPHP/prometheus_client_php.
Description
A prometheus exporter for the Laravel and the Lumen web framework.
It tracks latency and request counts by request method, route path and response code.
Installation
composer require gorerider/laravel-prometheus-exporter
Adapters
Then choose from three storage adapters: Memory (default), APCu and Redis can also be used.
APCu
Ensure apcu-bc is installed and enabled. If you're using the official PHP docker hub non-alpine image, have a look in the Dockerfile on how to install.
Redis
Ensure php redis is installed and enabled. If you're using the official PHP docker hub non-alpine image, have a look in the Dockerfile on how to install.
By default, it looks for a redis server at localhost:6379. The server
can be configured in config/prometheus_exporter.php
.
Laravel
If you're requiring this package in Laravel, middleware and route will be configured for you automatically.
Enable the Service Provider
In config/app.php
(if not already there):
Lumen
Register the ServiceProvider
In bootstrap/app.php
Add an endpoint for the metrics
In bootstrap/app.php
Configuration
Metrics are exposed on /metrics
endpoint, e.g. http://my-service.com/metrics
The configuration can be found in config/prometheus_exporter.php
.
All values can be configured via .env or environment variables.
name | description | env |
---|---|---|
adapter | Storage adapter to use: 'memory', 'apc' or 'redis' default: 'memory' | PROMETHEUS_EXPORTER_ADAPTER |
active_collectibles | Additional metric collectibles | n.a. |
buckets | HTTP requests latency histogram buckets | n.a. |
namespace | Name (prefix) to use in prometheus metrics. default: value in APP_NAME env var | PROMETHEUS_EXPORTER_NAMESPACE |
redis | Array of redis parameters | see prometheus_exporter.php for details |
opcache_metrics_namespace | Name (prefix) to use for OPCache metrics. default: opcache | PROMETHEUS_EXPORTER_OPCACHE_METRICS_NAMESPACE |
fpm_metrics_namespace | Name (prefix) to use for PHP-FPM metrics. default: fpm | PROMETHEUS_EXPORTER_FPM_METRICS_NAMESPACE |
Collectibles
If you want to disable any collectibles,
you'll need to remove entries from the prometheus_exporter.php
config.
Laravel
Run
Finally, remove collectibles in app/config/prometheus_exporter.php
Lumen
Copy src/config/prometheus_exporter.php
in this repo and add to your Lumen project
in the config directory.
Finally, remove collectibles in app/config/prometheus_exporter.php
Example /metrics
Note
that all HTTP requests are instrumented including the /metrics
endpoint itself.
All versions of laravel-prometheus-exporter with dependencies
illuminate/support Version ^7.22
promphp/prometheus_client_php Version ^2.7