lkaemmerling/prometheus_push_gateway_php

此包已被弃用且不再维护。作者建议使用 promphp/prometheus_push_gateway_php 包。

Prometheus Push Gateway 的 PHP 应用程序客户端。

v1.1.1 2022-04-11 18:49 UTC

This package is auto-updated.

Last update: 2022-04-11 19:32:47 UTC


README

Tests

此包提供了一个简单的 PHP API 来使用 Prometheus Push Gateway。它曾是 promphp/prometheus_client_php 的一部分,并在 Prometheus 客户端 PHP 版本 2.0.0 中被独立为一个单独的包。

它是如何工作的?

PushGateway 允许 Prometheus 从不可访问的系统(您的 Prometheus 无法访问的系统)获取指标。使用此库,您可以轻松地将您的指标发送到 PushGateway。

安装

将其作为 Composer 依赖项添加

composer require promphp/prometheus_push_gateway_php

使用方法

假设您有一个简单的计数器,并想将其发送到您的 PushGateway。

\Prometheus\CollectorRegistry::getDefault()
    ->getOrRegisterCounter('', 'some_quick_counter', 'just a quick measurement')
    ->inc();

// Now send it to the PushGateway:
$pushGateway = new \PrometheusPushGateway\PushGateway('http://192.168.59.100:9091');
$pushGateway->push(\Prometheus\CollectorRegistry::getDefault(), 'my_job', ['instance' => 'foo']);

也请参阅 示例

开发

依赖

黑盒测试

只需通过 docker-compose 启动 PushGateway

docker-compose up

使用 composer 捕获所有依赖项

docker run --rm --interactive --tty --volume $PWD:/app composer install

执行测试

docker-compose run phpunit vendor/bin/phpunit tests/Test/