vmorozov/laravel-prometheus
Composer 安装命令:
composer require vmorozov/laravel-prometheus
包简介
Prometheus client for laravel framework. Includes some of default metrics for any laravel application out of the box and ability to add custom metrics easily. .
README 文档
README
A Laravel package for integrating Prometheus metrics collection into your Laravel application.
This package makes it easy to collect and expose metrics for monitoring your application's performance and behavior.
Installation
- Install the package via composer:
composer require vmorozov/laravel-prometheus
- Publish vendor files:
php artisan vendor:publish --provider="VMorozov\\Prometheus\\PrometheusServiceProvider"
Upgrading version
- Update the package version in
composer.json - Run
composer update
- Run command to update configs:
php artisan vendor:publish --provider="VMorozov\\Prometheus\\PrometheusServiceProvider" --force
- Run clear stored metrics:
php artisan prometheus:clear_stored_metrics
Usage
This package provides default metrics that allow you to monitor response times (divided into buckets and percentiles) and request counts.
It also allows you to create custom metrics and collectors for your specific needs.
To see the collected metrics, go to the /metrics endpoint of your application.
This endpoint returns metrics in the Prometheus exposition format, which can be scraped by a Prometheus server.
You can clear stored metrics using the built-in prometheus:clear_stored_metrics command:
php artisan prometheus:clear_stored_metrics
Configuration
The package can be configured using the laravel-prometheus.php configuration file.
This file is published to your application's config directory when you run the vendor:publish command.
Key configuration options include:
- namespace: Prefix for all metrics (default: your APP_NAME env value)
- storage_type: How metrics data is stored (redis, in_memory, apcu)
- route_url: URL path for the metrics endpoint (default:
/metrics) - default_metrics_enabled: Whether default metrics are enabled (they are enabled by default)
- on_demand_metric_collectors: Collectors that run only when the metrics endpoint is accessed
For detailed configuration information, see the Configuration Documentation.
Default Metrics
The package includes two default metrics:
- Request Duration Histogram: Measures the duration of HTTP requests.
- Queue Size Gauge: Measures the size of Laravel queues (you have to configure which connections and queues to monitor).
For more information about the default metrics, see the Default Metrics Documentation.
Custom Metrics
You can create custom metrics to monitor specific aspects of your application. The package supports three types of metrics:
- Counter: A cumulative metric that only increases (requests_processed, users_registered, etc.)
- Gauge: A metric that can go up and down and represents current state of something (example: queue_size, cpu_load, etc.)
- Histogram: A metric that samples observations and counts them in buckets (when you need to have quantiles of your metric values)
For information on creating and using custom metrics, see the Custom Metrics Documentation.
On-Demand Metrics Collectors
On-Demand Metrics Collectors are classes that collect metrics only when the metrics endpoint is accessed.
This is useful for metrics that are expensive to collect or that don't need to be updated on every request.
For information on creating and using custom On-Demand Metrics Collectors, see the On-Demand Metrics Collectors Documentation.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
vmorozov/laravel-prometheus 适用场景与选型建议
vmorozov/laravel-prometheus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 848 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「vmorozov」 「laravel-prometheus」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vmorozov/laravel-prometheus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vmorozov/laravel-prometheus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vmorozov/laravel-prometheus 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Export Laravel metrics to Prometheus
Laravel library for providing trace ids in logs.
Package for fast setup for requests and responses logging for laravel http-client-based api clients
Laravel package for convenient usage of Event Driven Microservices communication using Event Backbone (Apache Kafka).
Export Laravel metrics to Prometheus
统计信息
- 总下载量: 848
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-23