gustamms / prometheus-laravel
Lib for prometheus connector
Installs: 101
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 4
Open Issues: 0
Type:project
Requires
- php: ^7.2.5 || ^8.0
- illuminate/routing: ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0 || ^9.0
- promphp/prometheus_client_php: ^2.7.1
README
To use
Run this command
composer require gustamms/prometheus-laravel
Copy the config/prometheus.php
to your laravel/lumen implementation
https://github.com/gustamms/prometheus-laravel/blob/main/src/config/prometheus.php
In bootstrap/app.php
add this configure
$app->configure('prometheus');
In bootstrap/app.php
add this register provider
$app->register(\Gustamms\PrometheusLaravel\Providers\PrometheusServiceProvider::class);
In bootstrap/app.php
add this middleware
$app->middleware([ ... \Gustamms\PrometheusLaravel\Middleware\PrometheusRouteMiddleware::class ]);
In .env
add and change the values of this lines
PROMETHEUS_STORAGE_ADAPTER=redis PROMETHEUS_REDIS_HOST=localhost PROMETHEUS_REDIS_PORT=6379 PROMETHEUS_REDIS_TIMEOUT=0.1 PROMETHEUS_REDIS_READ_TIMEOUT=10 PROMETHEUS_REDIS_PERSISTENT_CONNECTIONS=0 PROMETHEUS_REDIS_PREFIX=PROMETHEUS_ PROMETHEUS_NAMESPACE=application_name
How use for personal metrics?
use Gustamms\PrometheusLaravel\PrometheusCollector; class DoSomething { private $collector; public function __construct() { $this->collector = new PrometheusCollector(); } public function do(){ $this->collector->getOrRegisterCounter( 'do_method_use', 'Pass in Do method' ); $this->collector->getOrRegisterHistogram( 'histogram_sample', 'Histogram are made', 1.2, ['label1'], ['labelvalue1'] ); } }