Laravel Prometheus is a package that allows you to integrate Prometheus, a popular open-source monitoring and alerting toolkit, into your Laravel applications. Prometheus is widely used for monitoring various aspects of software systems, including metrics, time series data, and alerting.
This package uses Redis to do the client side aggregation and also need installed phpredis extension for communication with the Redis key-value store. To install the phpredis extension you can follow link below:
https://github.com/phpredis/phpredis/blob/develop/INSTALL.md
You can install the package via composer:
composer require tech-djoin/laravel-prometheus
You can publish the config file with:
php artisan vendor:publish --provider="TechDjoin\LaravelPrometheus\PrometheusServiceProvider" --tag="config"
This packages provides a middleware which can be added as a global middleware or as a single route.
// in `app/Http/Kernel.php`
protected $middleware = [
// ...
\TechDjoin\LaravelPrometheus\Middleware\MetricCollector::class
];
// in a routes file
Route::post('/dashboard', function () {
//
})->middleware(\TechDjoin\LaravelPrometheus\Middleware\MetricCollector::class);
This package adds a /metrics
end-point, enabled by default, which exposes all metrics gathered by collectors.
If you would like to protect this end-point, you can add secret value on LARAVEL_PROMETHEUS_SECRET
in your .env files, and you can only access the end-point using /metrics/{secret}
composer test
This project is licensed under the MIT License - see the LICENSE.md file for details.