denniswinter/prompush

简单的 Prometheus PushGateway 客户端

0.1.1 2016-10-19 15:15 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:14:32 UTC


README

Build Status

Simple HttpClient 包装的 Prometheus PushGateway。

安装

使用 Composer

composer require denniswinter/prompush

API

使用以下方式实例化客户端

<?php
$client = new PromPush\Client(new GuzzleHttp\Client([
    'base_url' => 'http://prometheus-pushgateway.example.com:9091']
));

将度量指标推送到网关

<?php
$data = [
    '# TYPE test_test_test summary',
    'test_test_test_sum{handler="push"} ' . $sum . "\n",
    'test_test_test_count{handler="push"} ' . $i . "\n"
];

$job = 'test_job';

$group = array('test_group_1', 'test_group_2');

$client->set($data, $job, $group);

替换网关上的指标

<?php
$data = [
    '# TYPE test_test_test summary',
    'test_test_test_sum{handler="push"} ' . $sum . "\n",
    'test_test_test_count{handler="push"} ' . $i . "\n"
];

$job = 'test_job';

$group = array('test_group_1', 'test_group_2');

$client->replace($data, $job, $group);

删除网关上的指标

<?php

$job = 'test_job';

$group = array('test_group_1', 'test_group_2');

$client->replace($job, $group);