Download the PHP package vermorag/laravel-prometheus-exporter without Composer

On this page you can find all versions of the php package vermorag/laravel-prometheus-exporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-prometheus-exporter

Laravel (and Lumen) Prometheus Exporter

A prometheus exporter package for Laravel and Lumen.

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 jimdo/prometheus_client_php into Laravel and Lumen.

Example

Head to examples/lumen-app to check out our awesome example application. To get it you'll have to clone the Laravel Prometheus Exporter repo, as the example is not included when downloaded from composer.

The example is a full project containing it's own README.md so you can check the library's functionality and the way it's intended to be used.

Installation

Add the repository to composer.json

Install the package via composer

After that you may enable facades and register the facade in your application's bootstrap/app.php

Then you should register the service provider in bootstrap/app.php

Please see below for instructions on how to enable metrics on Application routes, Guzzle calls and SQL queries.

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 copy the included prometheus.php to config/prometheus.php, edit it and use it in your application as follows:

Metrics

The package allows you to observe metrics on:

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 bootstrap/app.php:

The labels exported are

To observe Guzzle metrics, you should register the following provider in bootstrap/app.php:

The labels exported are

To observe SQL metrics, you should register the following provider in bootstrap/app.php:

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.

If redis is used, the PROMETHEUS_REDIS_HOST and PROMETHEUS_REDIS_PORT vars also need to be configured. Optionally you can change the PROMETHEUS_REDIS_TIMEOUT, PROMETHEUS_REDIS_READ_TIMEOUT and PROMETHEUS_REDIS_PERSISTENT_CONNECTIONS variables.

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

Example usage

This is an example usage for a Lumen application

Collector

This is an example collector implementation:

php


All versions of laravel-prometheus-exporter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0 || ^8.1 || ^8.2
guzzlehttp/guzzle Version ^7.4.2
illuminate/routing Version ^10.0 || ^11.0
illuminate/support Version ^10.0 || ^11.0
promphp/prometheus_client_php Version ^2.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vermorag/laravel-prometheus-exporter contains the following files

Loading the files please wait ....