tech-djoin / laravel-prometheus
Requires
- php: ^7.4|^8.0
- illuminate/support: ^6.0|^7.0|^8.0|^9.0|^10.0
- promphp/prometheus_client_php: ^2.7
Requires (Dev)
- orchestra/testbench: ^6.27
- pestphp/pest: ^1.23
- pestphp/pest-plugin-laravel: ^1.4
README
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
Installation
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"
Usage
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);
Exporting Metrics
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}
Testing
composer test
License
This project is licensed under the MIT License - see the LICENSE.md file for details.