dbstudios / prometheus-client-bundle
dbstudios/prometheus-client的Symfony包
Requires
- php: >=5.6
- dbstudios/prometheus-client: ^2.0
- symfony/config: ^2.8|^3.4|^4.0
- symfony/console: ^3.4
- symfony/dependency-injection: ^2.8|^3.4|^4.0
- symfony/http-kernel: ^2.8|^3.4|^4.0
This package is auto-updated.
Last update: 2024-09-09 03:48:52 UTC
README
要添加此包,请运行以下命令。
$ composer require dbstudios/prometheus-client-bundle
如果你的项目使用Symfony Flex,则该包应自动启用。如果不自动启用,则需要将DaybreakStudios\PrometheusClientBundle\DaybreakStudiosPrometheusClientBundle添加到你的包文件中。
接下来,如果您的config目录,您需要为此包添加基本配置。
dbstudios_prometheus: adapter: DaybreakStudios\PrometheusClient\Adapter\ApcuAdapter
基本配置应放置的位置将取决于您的Symfony版本。对于3.4及更早版本,应放置在app/config/config.yml中。对于较新的Symfony版本(4.0及以上),应放置在config/packages/dbstudios_prometheus.yaml中。
adapter的值必须是扩展了DaybreakStudios\PrometheusClient\Adapter\AdapterInterface的服务ID。有关内置适配器的列表,请参阅dbstudios/prometheus-client的文档。
配置
以下提供了此包的完整、注释过的配置。
dbstudios_prometheus: # The ID of a service implementing DaybreakStudios\PrometheusClient\Adapter\AdapterInterface. No services are # registered by default, so you will need to choose an appropriate adapter for your environment, register it, then # reference it here. adapter: DaybreakStudios\PrometheusClient\Adapter\ApcuAdapter # The ID of a service implementing DaybreakStudios\PrometheusClient\CollectorRegistryInterface, OR the # fully-qualified class name of a class implementing the aforementioned interface. In the second case, the bundle # will automatically register the provided class as a service, using the class name as it's service ID. # # If you're using the built-in collector registry, you do not need to provide a value here. registry: DaybreakStudios\PrometheusClient\CollectorRegistry # The metrics section contains options for the built-in metrics endpoint listener, which provides the information # Prometheus needs to scrape your application. metrics: # Whether or not the built-in metrics endpoint is enabled. If this option is false, you will need to implement # the metrics endpoint on your own (see the section titled "Custom Metrics Endpoint"). enabled: true # The path to use for the metrics endpoint. If `metrics.enabled` is false, this option is ignored. path: /metrics
自定义指标端点
默认情况下,此包注册了一个监听器,响应对dbstudios_prometheus.metrics.path的任何请求,并返回Prometheus从您的应用程序抓取指标所需的数据。如果您想自己实现此端点,请参阅DaybreakStudios\PrometheusClientBundle\Listeners\MetricsEndpointListener::onKernelRequest()以获取示例实现。