Download the PHP package cloudisle/laravel-prometheus without Composer
On this page you can find all versions of the php package cloudisle/laravel-prometheus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cloudisle/laravel-prometheus
More information about cloudisle/laravel-prometheus
Files in cloudisle/laravel-prometheus
Package laravel-prometheus
Short Description A Laravel package for Prometheus integration.
License MIT
Informations about the package laravel-prometheus
laravel-prometheus
A Laravel package for integrating Prometheus metrics into your Laravel application. This package provides a simple API for defining, registering, and exposing custom metrics, as well as a /metrics endpoint for Prometheus scraping.
Features
- Register and expose counters, gauges, histograms, and summaries
- Simple API via Metrics and Prometheus facades
- Configurable default labels and metric definitions
- Built-in
/metricsendpoint - Optional basic authentication for metrics endpoint
Installation
-
Install via Composer:
- (Optional) Publish the config files:
Configuration
The package provides two config files:
config/prometheus.php: Prometheus storage and endpoint settingsconfig/metrics.php: Default labels and metric definitions
prometheus.php
driver: Storage driver for metrics (memory,redis, orapcu)auth.enabled: Enable basic auth for/metricsendpointauth.username/auth.password: Credentials for basic auth
metrics.php
namespace: Default namespace for metricslabels: Default labels applied to all metrics (as an associative array)counters,gauges,histograms,summaries: Predefined metrics to register at boot. Each metric'slabelsshould be an array of label names (not key-value pairs).
Example:
Usage
Facades
Metrics
The Metrics facade provides a simple API for interacting with your metrics. When recording or incrementing metrics, you must provide label values in the same order as defined in the metric's labels array in the config. Default labels from the config are always prepended in order.
- If you provide a label value for a label defined in the config's
labels, it will override the default value for that label. - The order of label values must match the order of label names as defined in the metric's
labelsarray, after the default labels.
Prometheus
The Prometheus facade gives you direct access to the underlying Prometheus client:
Metrics Endpoint
The /metrics route is automatically registered and returns all metrics in Prometheus text format. You can secure it with basic auth by enabling it in prometheus.php config.
Error Handling
You can customize how metric registration errors are handled by binding your own implementation of CloudIsle\Prometheus\MetricErrorHandler in the service container.
Testing
This package is fully testable with Orchestra Testbench. See the tests/ directory for examples.
License
MIT
All versions of laravel-prometheus with dependencies
illuminate/support Version >=9.0
promphp/prometheus_client_php Version ^2.14