Package Data | |
---|---|
Maintainer Username: | triadev |
Maintainer Contact: | christopher.lorke@gmx.de (Christopher Lorke) |
Package Create Date: | 2017-07-18 |
Package Last Update: | 2020-05-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-09 03:00:48 |
Package Statistics | |
---|---|
Total Downloads: | 25,667 |
Monthly Downloads: | 30 |
Daily Downloads: | 4 |
Total Stars: | 28 |
Total Watchers: | 1 |
Total Forks: | 19 |
Total Open Issues: | 4 |
A laravel and lumen service provider to export metrics for prometheus.
composer require triadev/laravel-prometheus-exporter
The package is registered through the package discovery of laravel and Composer.
https://laravel.com/docs/5.7/packages
Once installed you can now publish your config file and set your correct configuration for using the package.
php artisan vendor:publish --provider="Triadev\PrometheusExporter\Provider\PrometheusExporterServiceProvider" --tag="config"
This will create a file config/prometheus-exporter.php
.
| Key | Env | Value | Description | Default | |:-------------:|:-------------:|:-------------:|:-----:|:-----:| | adapter | PROMETHEUS_ADAPTER | STRING | apc, redis, inmemory or push | apc | | namespace | --- | STRING | default: app | app | | namespace_http | --- | STRING | namespace for "RequestPerRoute-Middleware metrics" | http | | redis.host | PROMETHEUS_REDIS_HOST | STRING | redis host | 127.0.0.1 | redis.port | PROMETHEUS_REDIS_PORT | INTEGER | redis port | 6379 | | redis.timeout | --- | FLOAT | redis timeout | 0.1 | | redis.read_timeout | --- | INTEGER | redis read timeout | 10 | | push_gateway.address | PROMETHEUS_PUSH_GATEWAY_ADDRESS | STRING | push gateway address | localhost:9091 | | buckets_per_route | --- | STRING | histogram buckets for "RequestPerRoute-Middleware" | --- |
'buckets_per_route' => [
ROUTE-NAME => [10,20,50,100,200],
...
]
triadev/pe/metrics
A middleware to build metrics for "request_total" and "requests_latency_milliseconds" per route.
lpe.requestPerRoute
$router->get('requestPerRoute', function () {
return 'valid';
})->middleware('lpe.requestPerRoute')->name('requestPerRoute');
app_requests_latency_milliseconds_bucket{route="requestPerRoute",method="GET",status_code="200",le="0.005"} 0 ... app_requests_latency_milliseconds_count{route="requestPerRoute",method="GET",status_code="200"} 1 app_requests_latency_milliseconds_sum{route="requestPerRoute",method="GET",status_code="200"} 6 app_requests_total{route="requestPerRoute",method="GET",status_code="200"} 1
If you do find an issue, please feel free to report it with GitHub's bug tracker for this project.
Alternatively, fork the project and make a pull request. :)
Please see CONTRIBUTING for details.
The code for LaravelPrometheusExporter is distributed under the terms of the MIT license (see LICENSE).