PHP code example of promphp / prometheus_client_php
1. Go to this page and download the library: Download promphp/prometheus_client_php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
promphp / prometheus_client_php example snippets
\Prometheus\CollectorRegistry::getDefault()
->getOrRegisterCounter('', 'some_quick_counter', 'just a quick measurement')
->inc();
$registry = \Prometheus\CollectorRegistry::getDefault();
$counterA = $registry->registerCounter('test', 'some_counter', 'it increases', ['type']);
$counterA->incBy(3, ['blue']);
// once a metric is registered, it can be retrieved using e.g. getCounter:
$counterB = $registry->getCounter('test', 'some_counter')
$counterB->incBy(2, ['red']);
$registry = new CollectorRegistry(new APCng());
or
$registry = new CollectorRegistry(new APC());
$registry = new CollectorRegistry(new \PDO('mysql:host=localhost;dbname=prometheus', 'username', 'password'));
or
$registry = new CollectorRegistry(new \PDO('sqlite::memory:'));
sh
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.