<?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 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); }
<?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__) . '/../vendor/autoload.php'; $client = new Prometheus\Client(['base_uri' => 'http://localhost:9091/metrics/job/']); $guage = $client->newGauge(['namespace' => 'php_client', 'subsystem' => 'testing', 'name' => 'Guage', 'help' => 'Testing the PHPClients guage']); $job_id = uniqid(); while (true) { $guage->set(['key1' => 'val1'], rand(1, 50)); $guage->set(['key2' => 'val2'], rand(1, 50)); echo "attempting a push\n"; $client->pushMetrics("pretend_server", $job_id); echo "push done\n"; $sleepTime = rand(1, 5); echo "sleeping {$sleepTime}\n"; sleep($sleepTime); }
<?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();