예제 #1
1
<?php

require_once dirname(__FILE__) . '/../vendor/autoload.php';
$client = new Prometheus\Client(['base_uri' => 'http://localhost:9091/metrics/job/']);
$counter = $client->newCounter(['namespace' => 'php_client', 'subsystem' => 'testing', 'name' => 'counter', 'help' => 'Testing the PHPClients Counter']);
$job_id = uniqid();
while (true) {
    $counter->increment(['url' => 'home.php', 'status_code' => 200], rand(1, 50));
    $counter->increment(['url' => 'home.php', 'status_code' => 404], rand(1, 50));
    $client->pushMetrics("pretend_server", $job_id);
    $sleepTime = rand(1, 20);
    echo "sleeping {$sleepTime}\n";
    sleep($sleepTime);
}
예제 #2
0
<?php

require_once dirname(__FILE__) . '/../src/Client.php';
$client = new Prometheus\Client(['base_uri' => 'http://localhost:9091/metrics/job/']);
$histogram = $client->newHistogram(['namespace' => 'meta_data', 'subsystem' => 'tv', 'name' => 'elements_per_hit', 'help' => 'Testing the PHPClients Histogram', 'buckets' => [10, 25, 50, 75, 100]]);
while (true) {
    $histogram->observe(['domain' => 'hulu'], rand(0, 100));
    $histogram->observe(['domain' => 'crunchyroll'], rand(0, 100));
    $client->pushMetrics("foreign_language", "test_server_0");
    echo "sleeping 5\n";
    sleep(5);
}