<?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); }
<?php require_once '../vendor/autoload.php'; $client = new Prometheus\Client(['base_uri' => 'http://192.168.229.173:9091']); $counter = $client->newCounter(['namespace' => 'viacom', 'subsystem' => 'prometheus', 'name' => 'count', 'help' => 'Counting some numbers']); $counter->increment(['fail' => 1]); $counter->increment(['fail' => 1]); $counter->increment(['fail' => 1]); $counter->increment(['fail' => 1]); $counter->increment(['happy' => 2]); $counter->increment(['happy' => 2]); $counter->increment(['lock' => 3]); $counter->increment(['lock' => 4]); $client->sendStats();
<?php require_once dirname(__FILE__) . '/../src/Client.php'; $client = new Prometheus\Client(); $counter = $client->newCounter(['namespace' => 'louddoor', 'subsystem' => 'promotions', 'name' => 'TestCounter', 'help' => 'Some testing counter']); $counter->increment(['promo' => 'ABC']); $counter->increment(['promo' => 'ABC']); $counter->increment(['promo' => 'ABC']); $counter->increment(['promo' => 'ABC']); $counter->increment(['promo' => 'CDE']); $counter->increment(['promo' => 'CDE']); $counter->increment(['promo' => 'EFG']); $counter->increment(['promo' => 'HIJ'], 3); // Increment by 3 instead print $client->serialize();