PHP code example of building5 / apache-exporter

1. Go to this page and download the library: Download building5/apache-exporter 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/ */

    

building5 / apache-exporter example snippets



ApacheExporter\Exporter::simple();


use ApacheExporter\Exporter;
use Prometheus\CollectorRegistry;
use Prometheus\RenderTextFormat;
use Prometheus\Storage\InMemory;

$registry = new CollectorRegistry(new InMemory());
$renderer = new RenderTextFormat();

Exporter::export($registry);

// register other stats you want here

header('Content-type: ' . RenderTextFormat::MIME_TYPE);
echo $renderer->render($registry->getMetricFamilySamples());