lkaemmerling / prometheus_push_gateway_php
v1.1.1
2022-04-11 18:49 UTC
Requires
- php: ^7.2|^8.0
- guzzlehttp/guzzle: ^6.3|^7.0
- promphp/prometheus_client_php: ^1.0|^2.0
Requires (Dev)
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.12.50
- phpstan/phpstan-phpunit: ^0.12.16
- phpstan/phpstan-strict-rules: ^0.12.5
- phpunit/phpunit: ^8.4|^9.4
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2022-04-11 19:32:47 UTC
README
此包提供了一个简单的 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']);
也请参阅 示例。
开发
依赖
- PHP ^7.2 | ^8.0
- Composer
黑盒测试
只需通过 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/