PromPush
, (*1)
Simple HttpClient wrapper of Prometheus PushGateway., (*2)
Installation
Using Composer:, (*3)
composer require denniswinter/prompush
API
Instantiate client using:, (*4)
<?php
$client = new PromPush\Client(new GuzzleHttp\Client([
'base_url' => 'http://prometheus-pushgateway.example.com:9091']
));
Push metrics to Gateway:, (*5)
<?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);
Replace metrics on Gateway:, (*6)
<?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);
Delete metrics on Gateway:, (*7)
<?php
$job = 'test_job';
$group = array('test_group_1', 'test_group_2');
$client->replace($job, $group);