PHP code example of promphp / prometheus_push_gateway_php

1. Go to this page and download the library: Download promphp/prometheus_push_gateway_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_push_gateway_php example snippets


\Prometheus\CollectorRegistry::getDefault()
    ->getOrRegisterCounter('', 'some_quick_counter', 'just a quick measurement')
    ->inc();

// Now send it to the PushGateway:
$pushGateway = new \PrometheusPushGateway\PushGateway('http://192.168.59.100:9091');
$pushGateway->push(\Prometheus\CollectorRegistry::getDefault(), 'my_job', ['instance' => 'foo']);