Download the PHP package saschahemleb/laravel-prometheus-exporter without Composer
On this page you can find all versions of the php package saschahemleb/laravel-prometheus-exporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download saschahemleb/laravel-prometheus-exporter
More information about saschahemleb/laravel-prometheus-exporter
Files in saschahemleb/laravel-prometheus-exporter
Package laravel-prometheus-exporter
Short Description A Prometheus exporter for Laravel
License MIT
Informations about the package laravel-prometheus-exporter
Laravel Prometheus Exporter
A prometheus exporter package for Laravel.
Introduction
Prometheus is a time-series database with a UI and sophisticated querying language (PromQL) that can scrape metrics, counters, gauges and histograms over HTTP.
This package is a wrapper bridging promphp/prometheus_client_php into Laravel.
Installation
Install the package via composer
Please see below for instructions on how to enable metrics on Application routes.
Configuration
The package has a default configuration which uses the following environment variables.
To customize the configuration values you can either override the environment variables above (usually this is done in your application's .env
file), or you can publish the included prometheus.php
to config/prometheus.php
.
Metrics
The package allows you to observe metrics on:
- Application routes. Metrics on request method, request path and status code.
- SQL queries. Metrics on SQL query and query type.
In order to observe metrics in application routes (the time between a request and response),
you should register the following middleware in your application's app/Http/Kernel.php
:
The labels exported are
SQL metrics are observed ootb. The labels exported are
Note: you can disable logging the full query by turning off the configuration of PROMETHEUS_COLLECT_FULL_SQL_QUERY
.
Storage Adapters
The storage adapter is used to persist metrics across requests. The memory
adapter is enabled by default, meaning
data will only be persisted across the current request.
We recommend using the redis
or apc
adapter in production
environments. Of course your installation has to provide a Redis or APC implementation.
The PROMETHEUS_STORAGE_ADAPTER
environment variable is used to specify the storage adapter.
Exporting Metrics
The package adds a /metrics
endpoint, enabled by default, which exposes all metrics gathered by collectors.
This can be turned on/off using the PROMETHEUS_METRICS_ROUTE_ENABLED
environment variable,
and can also be changed using the PROMETHEUS_METRICS_ROUTE_PATH
environment variable.
Collectors
A collector is a class, implementing the CollectorInterface, which is responsible for collecting data for one or many metrics.
Please see the Example included below.
You can auto-load your collectors by adding them to the collectors
array in the prometheus.php
config.
Examples
Collector
This is an example collector implementation:
php
- $exporter->registerCounter('search_requests_total', 'The total number of search requests.');
All versions of laravel-prometheus-exporter with dependencies
illuminate/support Version ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
illuminate/routing Version ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
promphp/prometheus_client_php Version ^2.2.1
guzzlehttp/guzzle Version ^6.3 || ^7.0