1. Go to this page and download the library: Download previousnext/php-prometheus 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/ */
previousnext / php-prometheus example snippets
$gauge = new Gauge("foo", "bar", "A test gauge");
$gauge->set(100, ['baz' => 'wiz']);
$gauge->set(90, ['wobble' => 'wibble', 'bing' => 'bong']);
$gauge->set(0);
$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($gauge, 'prometheus');
$counter = new Counter("foo", "bar", "A counter for testing");
$counter->set(100, ['baz' => 'wiz']);
$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($counter, 'prometheus');