itk-dev/metrics-bundle

为 Prometheus 提供指标

安装量: 6,182

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 4

分支: 0

开放问题: 0

类型:symfony-bundle

1.1.0 2024-02-15 09:50 UTC

This package is auto-updated.

Last update: 2024-09-15 11:01:05 UTC


README

此包是 Symfony 的包装器,使得暴露 Prometheus 指标变得稍微容易一些。

它支持导出 Opcache 和 APCu 指标,以及您应用程序的自定义指标。

配置

支持将指标信息存储在 3 个不同的存储适配器中。默认推荐使用 Redis,因为它在重启后持久化。所以如果 Prometheus 拉取器没有收集数据,您不会丢失任何数据。

默认配置

itkdev_metrics:
  # Prefix exported metrics (should be application name)
  namespace: ItkDevApp

  # Storage adapter to use
  adapter:
    type: redis # One of "apcu"; "memory"; "redis"

    # Connection options is only used by redis adapter
    options:
      host: 127.0.0.1
      port: 6379
      password: ~

  # Export metrics for these extensions
  extensions:
    opcache: false
    apcu: false

路由

该包暴露了 /metrics 路由,如果该路径已被占用,可以通过在 config/routes 下创建路由文件来添加前缀。

itkdev_metrics:
  prefix: '/custom/path/prefix'
  resource: '@ItkDevMetricsBundle/Resources/config/routes.xml'

服务

该包包含一个公共服务 MetricsService,可用于收集自定义指标。它支持 Prometheus 的标准指标(计数器、仪表、直方图)。请参阅函数文档了解它们之间的区别以及如何使用它们。

更多信息请参阅: https://prometheus.ac.cn/docs/concepts/metric_types/