Download the PHP package renoki-co/laravel-exporter-contracts without Composer
On this page you can find all versions of the php package renoki-co/laravel-exporter-contracts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download renoki-co/laravel-exporter-contracts
More information about renoki-co/laravel-exporter-contracts
Files in renoki-co/laravel-exporter-contracts
Package laravel-exporter-contracts
Short Description Base contracts implementation for Prometheus exports in Laravel.
License Apache-2.0
Homepage https://github.com/renoki-co/laravel-exporter-contracts
Informations about the package laravel-exporter-contracts
Laravel Prometheus Exporter
Base contracts implementation for Prometheus exports in Laravel.
🤝 Supporting
If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, sponsor our work with Github Sponsors. 📦
🚀 Installation
You can install the package via composer:
Publish the config:
🙌 Usage
All you have to do is to create a \RenokiCo\LaravelExporter\Metric
class that defines how the values will update on each Prometheus call to scrap, and the definition of the collector.
By default, metrics are available on the /exporter/group/metrics
endpoint and you can point Prometheus towards it for scraping. (i.e. http://localhost/exporter/group/metrics
)
You can choose one of the following classes to extend:
\RenokiCo\LaravelExporter\GaugeMetric
for gauges\RenokiCo\LaravelExporter\CounterMetric
for counters
For example, you can define gauges for users:
In your AppServiceProvider
's boot()
method, register your metric:
You don't need to set the values. When the Prometheus scraper will make the request for metrics, the gauge will automatically be set.
Labelling
You may label data by setting default values (i.e. server name, static data, etc.) and on-update.
Grouping
If you wish to have separate endpoints for different metrics, consider specifying it in the $showsOnGroup
property:
Under the hood, Laravel Exporter registers a route that allows you to scrape any group:
To scrape this specifc metric (and other metrics that are associated with this group), the endpoint is /exporter/group/metrics-reloaded
(i.e. http://localhost/exporter/group/metrics-reloaded
).
Sending string responses
In some cases you may want to export the string-alike, Prometheus-formatted response without using the internal metrics.
To do so, use the exportResponse
function. The function will return the response directly instead of relying on the Metric
class and subsequent class registrations via the Exporter::register()
function.
When accessing the /metrics
endpoint, the response will be the one declared earlier.
For custom groups, pass a second parameter with the group name:
🐛 Testing
🤝 Contributing
Please see CONTRIBUTING for details.
🔒 Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
🎉 Credits
- Alex Renoki
- All Contributors
All versions of laravel-exporter-contracts with dependencies
promphp/prometheus_client_php Version ^2.4
illuminate/config Version ^8.83|^9.0.1
illuminate/routing Version ^8.83|^9.0.1
illuminate/support Version ^8.83|^9.0.1