定制 3slab/vdm-prometheus-bundle 二次开发

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

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

3slab/vdm-prometheus-bundle

Composer 安装命令:

composer require 3slab/vdm-prometheus-bundle

包简介

Provide a metric endpoint to be pulled by Prometheus

README 文档

README

Build Status

This bundle provides a metric endpoint to be pulled by Prometheus. It uses the prometheus client from PromPHP

It collects the following metrics :

  • Memory in byte per route
  • Number of call to the API per response code
  • Response size in bytes
  • Request execution time in seconds

Response example :

# HELP php_info Information about the PHP environment.
# TYPE php_info gauge
php_info{version="7.3.11-0ubuntu0.19.10.6"} 1
# HELP vdm_sf_app_call_total Number of call to the app
# TYPE vdm_sf_app_call_total counter
vdm_sf_app_call_total{app="app",route=""} 1
vdm_sf_app_call_total{app="app",route="error_route"} 1
vdm_sf_app_call_total{app="app",route="success_route"} 2
# HELP vdm_sf_app_memory_usage Memory in byte per route
# TYPE vdm_sf_app_memory_usage gauge
vdm_sf_app_memory_usage{app="app",route=""} 25165824
vdm_sf_app_memory_usage{app="app",route="error_route"} 25165824
vdm_sf_app_memory_usage{app="app",route="success_route"} 25165824
# HELP vdm_sf_app_response_code_total Number of call to the API per response code
# TYPE vdm_sf_app_response_code_total counter
vdm_sf_app_response_code_total{app="app",route="",http_code="404"} 1
vdm_sf_app_response_code_total{app="app",route="error_route",http_code="500"} 1
vdm_sf_app_response_code_total{app="app",route="success_route",http_code="200"} 2
# HELP vdm_sf_app_response_size Response size in bytes
# TYPE vdm_sf_app_response_size gauge
vdm_sf_app_response_size{app="app",route=""} 305784
vdm_sf_app_response_size{app="app",route="error_route"} 5
vdm_sf_app_response_size{app="app",route="success_route"} 7
# HELP vdm_sf_app_response_time Request execution time in seconds
# TYPE vdm_sf_app_response_time gauge
vdm_sf_app_response_time{app="app",route=""} 81.976890563965
vdm_sf_app_response_time{app="app",route="error_route"} 0.10800361633301
vdm_sf_app_response_time{app="app",route="success_route"} 0.09608268737793

Installation

composer require 3slab/vdm-prometheus-bundle

And load the routes in routing.yml :

vdm_prometheus:
  resource: "@VdmPrometheusBundle/Resources/config/routing.yml"
  prefix:   /

Configuration

Put your configuration in config/packages/vdm_prometheus.yaml file. This is the default :

vdm_prometheus:
  app: app
  namespace: vdm
  register_default_metrics: true
  secret: ~
  metrics_path: /metrics
  storage:
    type: default
Parameter Default Description
vdm_prometheus.app app set the value of the app tag on all metrics
vdm_prometheus.namespace vdm prefix all the metrics' label
vdm_prometheus.register_default_metrics true app PromPHP Prometheus Client default metric
vdm_prometheus.secret null if set, you need to provide the secret as a GET parameter secret or in the
header VDM-Prometheus-Secret to get the detailed result of the metrics in the response body.
vdm_prometheus.metrics_path /metrics Change the path of the metric endpoint.
vdm_prometheus.storage see below Configure the storage to store metrics between requests

Metrics storage

To persist metrics between requests, you have to store them in persistent storage.

The following storage are supported :

  • In Memory (the default)
vdm_prometheus:
  storage:
    type: memory
  • APCu
vdm_prometheus:
  storage:
    type: apcu

You need to have the php module ext-apc installed.

  • Redis
vdm_prometheus:
  storage:
    type: redis
    settings:
      host: '127.0.0.1'
      port: 6379
      timeout: 0.1
      read_timeout: 10
      persistent_connections: false
      password: ~

You need to have the php module ext-redis installed.

  • Custom
vdm_prometheus:
  storage:
    type: custom
    service: my_service_id

With custom storage, you need to provide a Symfony service which implements the PromPHP Storage Adapter Interface

Custom collectors

You can create your own collector if you want to track other information.

Grafana

This bundle provides a grafana dashboard setup to work with default configuration for settings vdm_prometheus.app and vdm_prometheus.namespace.

3slab/vdm-prometheus-bundle 适用场景与选型建议

3slab/vdm-prometheus-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 944 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 3slab/vdm-prometheus-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2020-12-14