承接 vmorozov/laravel-prometheus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vmorozov/laravel-prometheus

最新稳定版本:v1.3.2

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

Latest Version on Packagist Tests Total Downloads

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

  1. Install the package via composer:
composer require vmorozov/laravel-prometheus
  1. Publish vendor files:
php artisan vendor:publish --provider="VMorozov\\Prometheus\\PrometheusServiceProvider"

Upgrading version

  1. Update the package version in composer.json
  2. Run
composer update
  1. Run command to update configs:
php artisan vendor:publish --provider="VMorozov\\Prometheus\\PrometheusServiceProvider" --force
  1. 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:

  1. Request Duration Histogram: Measures the duration of HTTP requests.
  2. 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:

  1. Counter: A cumulative metric that only increases (requests_processed, users_registered, etc.)
  2. Gauge: A metric that can go up and down and represents current state of something (example: queue_size, cpu_load, etc.)
  3. 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.

统计信息

  • 总下载量: 763
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固