PHP code example of tweedegolf / prometheus-client
1. Go to this page and download the library: Download tweedegolf/prometheus-client 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/ */
tweedegolf / prometheus-client example snippets
use TweedeGolf\PrometheusClient\CollectorRegistry;
use TweedeGolf\PrometheusClient\Storage\ApcuAdapter;
$registry = new CollectorRegistry(new ApcuAdapter());
$registry->createCounter('requests', [], null, true);
$registry->createGauge('traffic', ['endpoint'], 'Active traffic per endpoint', true);
use TweedeGolf\PrometheusClient\Format\TextFormatter;
$formatter = new TextFormatter();
header('Content-Type', $formatter->getMimeType());
echo $formatter->format($registry->collect());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.