PHP code example of alan / msf-prometheus

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

    

alan / msf-prometheus example snippets


$config['redis']['prometheus']['ip']               = '127.0.0.1';
$config['redis']['prometheus']['port']             = 6379;
$config['redis']['prometheus']['select']           = 0;
$config['redis']['prometheus']['password']         = '123456';

   \alan\msf_prometheus\di\ClassLoader::init();
   

   
   
   namespace App\Controllers;
   
   use alan\msf_prometheus\prometheus\MetricsTrait;
   use PG\MSF\Controllers\Controller;
   
   class Metrics extends Controller
   {
       use MetricsTrait;
   
       public function actionIndex(){
           $result = yield $this->metricsOutput();
           $this->getContext()->getOutput()->setContentType("text/plain; version=0.0.4;charset=UTF-8");
           $this->getContext()->getOutput()->end($result);
       }
   }