![]() retrieve a counter $counter = $exporter-> getCounter( 'search_requests_total') $counter-> inc() // increment by 1 $counter-> incBy( 2, ) create a counter (with labels) $counter = $exporter-> registerCounter( 'search_requests_total', 'The total number of search requests.', ) $counter-> inc() // increment by 1 $counter-> incBy( 2) the following methods can be used to create and interact with counters, gauges and histograms directly // these methods will typically be called by collectors, but can be used to register any custom metrics directly, // without the need of a collector // create a counter $counter = $exporter-> registerCounter( 'search_requests_total', 'The total number of search requests.') export all metrics // this is called automatically when the /metrics end-point is hit retrieve a collector by name $collector = $exporter-> getCollector( 'user') $exporter-> registerCollector( $collector) register a new collector $collector = new \ My\ New\ Collector() or $exporter = Prometheus:: getFacadeRoot() Usage // retrieve the exporter $exporter = app(\ Superbalist\ LaravelPrometheusExporter::class) You can auto-load your collectors by adding them to the collectors array in the prometheus.php config. Please see the ExampleCollector included in this repository. CollectorsĪ collector is a class, implementing the CollectorInterface, which is responsible for If you would like to protect this end-point, you can write any custom middleware and enable it using This can be turned on/off using the PROMETHEUS_METRICS_ROUTE_ENABLED var, and can also be changed using the The package adds a /metrics end-point, enabled by default, which exposes all metrics gathered by collectors. ![]() If redis is used, the REDIS_HOST and REDIS_PORT vars also need to be configured. The PROMETHEUS_STORAGE_ADAPTER env var is used to specify the storage adapter. We recommend using the redis or apc adapter in production The memory adapter is enabled by default, meaningÄata will only be persisted across the current request. The storage adapter is used to persist metrics across requests. You can then edit the generated config at app/config/prometheus.php. php artisan vendor:publish -provider= "Superbalist\LaravelPrometheusExporter\PrometheusServiceProvider " To customize the configuration file, publish the package configuration using Artisan. The package has a default configuration which uses the following environment variables. 'Prometheus' => Superbalist\ LaravelPrometheusExporter\ PrometheusFacade::class, Register the facade in app.php 'aliases' => [ Superbalist\ LaravelPrometheusExporter\ PrometheusServiceProvider::class, Register the service provider in app.php 'providers' => [ Installation composer require superbalist/laravel-prometheus-exporter This package is a wrapper bridging jimdo/prometheus_client_php into Laravel.
0 Comments
Leave a Reply. |