定制 vntrungld/prometheus-exporter-php-fpm-collector 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

vntrungld/prometheus-exporter-php-fpm-collector

Composer 安装命令:

composer require vntrungld/prometheus-exporter-php-fpm-collector

包简介

Php-fpm Collector for Prometheus Exporter

README 文档

README

Latest Version on Packagist Total Downloads Tests License

A PHP-FPM metrics collector for Prometheus Exporter in Laravel applications. This package collects PHP-FPM pool status and process-level metrics and exposes them in Prometheus format.

Requirements

Laravel PHP Package
6.x 7.2 - 8.0 1.x
7.x 7.2 - 8.0 1.x
8.x 7.3 - 8.1 1.x
9.x 8.0 - 8.2 1.x
10.x 8.1 - 8.3 1.x
11.x 8.2 - 8.4 1.x
12.x 8.2 - 8.4 1.x

Installation

Install via Composer:

composer require vntrungld/prometheus-exporter-php-fpm-collector

The package uses Laravel's auto-discovery, so the service provider will be automatically registered.

Configuration

Add the collector set to your prometheus-exporter configuration file (config/prometheus-exporter.php):

return [
    // ... other config options

    'collector_sets' => [
        \Vntrungld\PrometheusExporterPhpFpmCollector\PhpFpmCollectorSet::class,
        // ... other collector sets
    ],
];

Available Metrics

Pool-Level Metrics

Metric Name Type Description Labels
fpm_up Gauge PHP-FPM pool availability (1=up, 0=down) pool
fpm_accepted_connections Gauge Total number of accepted connections pool
fpm_active_processes Gauge Number of active processes pool
fpm_idle_processes Gauge Number of idle processes pool
fpm_listen_queue Gauge Current listen queue size pool
fpm_listen_queue_length Gauge Maximum listen queue length pool
fpm_max_active_processes Gauge Maximum active processes reached pool
fpm_max_children_reached Gauge Times max children limit was reached pool
fpm_max_listen_queue Gauge Maximum listen queue reached pool
fpm_slow_requests Gauge Number of slow requests pool
fpm_start_since Gauge Seconds since FPM started pool
fpm_total_processes Gauge Total number of processes in pool pool

Process-Level Metrics

Metric Name Type Description Labels
fpm_process_last_request_cpu Gauge CPU usage for last request pool, child
fpm_process_last_request_memory Gauge Memory usage for last request pool, child
fpm_process_request_duration Gauge Request duration pool, child
fpm_process_request_length Gauge Request content length pool, child
fpm_process_requests Gauge Total requests served by process pool, child
fpm_process_state Gauge Process state indicator pool, child, state

Process States

The fpm_process_state metric uses the following state labels:

  • Idle - Process is idle
  • Getting request informations - Process is getting request info
  • Reading headers - Process is reading request headers
  • Running - Process is executing
  • Ending - Process is ending request
  • Finishing - Process is finishing

Example Output

# HELP fpm_up PHP-FPM pool availability
# TYPE fpm_up gauge
fpm_up{pool="www"} 1

# HELP fpm_active_processes The number of active processes
# TYPE fpm_active_processes gauge
fpm_active_processes{pool="www"} 3

# HELP fpm_idle_processes The number of idle processes
# TYPE fpm_idle_processes gauge
fpm_idle_processes{pool="www"} 2

# HELP fpm_process_state Process state indicator
# TYPE fpm_process_state gauge
fpm_process_state{pool="www",child="0",state="Idle"} 1
fpm_process_state{pool="www",child="0",state="Running"} 0
fpm_process_state{pool="www",child="1",state="Idle"} 0
fpm_process_state{pool="www",child="1",state="Running"} 1

PHP-FPM Configuration

For this collector to work, PHP-FPM must be configured to expose status. Ensure your PHP-FPM pool configuration has:

pm.status_path = /status

The collector uses PHP's built-in fpm_get_status() function which is available when running under PHP-FPM.

Testing

Run the test suite:

composer test

Or with PHPUnit directly:

vendor/bin/phpunit

Changelog

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email vn.trungld@gmail.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

vntrungld/prometheus-exporter-php-fpm-collector 适用场景与选型建议

vntrungld/prometheus-exporter-php-fpm-collector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.45k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 08 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Prometheus Exporter」 「Php-fpm Collector」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vntrungld/prometheus-exporter-php-fpm-collector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vntrungld/prometheus-exporter-php-fpm-collector 我们能提供哪些服务?
定制开发 / 二次开发

基于 vntrungld/prometheus-exporter-php-fpm-collector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-14