2017 © Pedro Peláez
 

library laravel-prometheus-exporter

A laravel service provider to export metrics.

image

triadev/laravel-prometheus-exporter

A laravel service provider to export metrics.

  • Sunday, April 1, 2018
  • by triadev
  • Repository
  • 1 Watchers
  • 2 Stars
  • 3,607 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 10 Versions
  • 50 % Grown

The README.md

LaravelPrometheusExporter

Software license ![Travis][ico-travis] Coveralls CodeCov Scrutinizer Code Quality ![Latest stable][ico-version-stable] Monthly installs Total Downloads Average time to resolve an issue Percentage of issues still open, (*1)

A laravel and lumen service provider to export metrics for prometheus., (*2)

Supported laravel versions

Laravel 5.6 ![Laravel 5.7][icon-l57] Laravel 5.8 ![Laravel 6.0][icon-l60], (*3)

Supported lumen versions

Lumen 5.6 ![Lumen 5.7][icon-lumen57] Lumen 5.8 ![Lumen 6.0][icon-lumen60], (*4)

Main features

  • Metrics with APC
  • Metrics with Redis
  • Metrics with InMemory
  • Metrics with the push gateway
  • Request per route middleware (total and duration metrics)

Installation

Composer

composer require triadev/laravel-prometheus-exporter, (*5)

Application

The package is registered through the package discovery of laravel and Composer., (*6)

https://laravel.com/docs/5.8/packages, (*7)

Once installed you can now publish your config file and set your correct configuration for using the package., (*8)

php artisan vendor:publish --provider="Triadev\PrometheusExporter\Provider\PrometheusExporterServiceProvider" --tag="config"

This will create a file config/prometheus-exporter.php., (*9)

Configuration

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, REDIS_HOST STRING redis host 127.0.0.1
redis.port PROMETHEUS_REDIS_PORT, REDIS_PORT INTEGER redis port 6379
redis.password PROMETHEUS_REDIS_PASSWORD, REDIS_PASSWORD STRING redis password null
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

'buckets_per_route' => [
    ROUTE-NAME => [10,20,50,100,200],
    ...
]

Usage

Get metrics

Laravel

When you are using laravel you can use the default http endpoint:, (*10)

triadev/pe/metrics, (*11)

Of course you can also register your own route. Here is an example:, (*12)

Route::get(
    ROUTE,
    \Triadev\PrometheusExporter\Controller\LaravelController::class . '@metrics'
);

Lumen

When you are using lumen you must register the route on your own. Here is an example:, (*13)

Route::get(
    ROUTE,
    \Triadev\PrometheusExporter\Controller\LumenController::class . '@metrics'
);

Middleware

RequestPerRoute

A middleware to build metrics for "request_total" and "requests_latency_milliseconds" per route., (*14)

Alias

lpe.requestPerRoute, (*15)

Metrics
  1. requests_total (inc)
  2. requests_latency_milliseconds (histogram)
Example
$router->get('/test/route', function () {
    return 'valid';
})->middleware('lpe.requestPerRoute');

app_requests_latency_milliseconds_bucket{route="/test/route",method="GET",status_code="200",le="0.005"} 0 ... app_requests_latency_milliseconds_count{route="/test/route",method="GET",status_code="200"} 1 app_requests_latency_milliseconds_sum{route="/test/route",method="GET",status_code="200"} 6 app_requests_total{route="/test/route",method="GET",status_code="200"} 1, (*16)

Roadmap

  • histogram buckets per route (RequestPerRoute)

Reporting Issues

If you do find an issue, please feel free to report it with GitHub's bug tracker for this project., (*17)

Alternatively, fork the project and make a pull request. :), (*18)

Testing

  1. docker-compose up
  2. docker exec fpm ./vendor/phpunit/phpunit/phpunit

Contributing

Please see CONTRIBUTING for details., (*19)

Credits

Other

Author

License

The code for LaravelPrometheusExporter is distributed under the terms of the MIT license (see LICENSE)., (*20)

The Versions

01/04 2018

dev-master

9999999-dev

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

01/04 2018

v1.4.1

1.4.1.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

01/04 2018

v1.4.0

1.4.0.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

03/10 2017

v1.3.1

1.3.1.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

11/08 2017

v1.3.0

1.3.0.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

10/08 2017

v1.2.0

1.2.0.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

01/08 2017

v1.1.1

1.1.1.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

01/08 2017

v1.1.0

1.1.0.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

28/07 2017

v1.0.1

1.0.1.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus

28/07 2017

v1.0.0

1.0.0.0

A laravel service provider to export metrics.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christopher Lorke

laravel metrics prometheus