PHP code example of metrics-tracker / watchlog

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

    

metrics-tracker / watchlog example snippets


use MetricsTracker\Watchlog;

$watchlog = new Watchlog();

// Increment a metric (default is 1)
$watchlog->increment('page_views');
$watchlog->increment('page_views', 5);

// Decrement a metric (default is 1)
$watchlog->decrement('active_users');
$watchlog->decrement('active_users', 2);

// Set a gauge value
$watchlog->gauge('memory_usage', 512);

// Set a percentage value (0-100)
$watchlog->percentage('cpu_usage', 75);

// Set a system byte value
$watchlog->systembyte('disk_space', 1024000);

use MetricsTracker\Watchlog;

// Create client with explicit agent URL for Docker
$watchlog = new Watchlog('http://watchlog-agent:3774');

$watchlog->increment('page_views', 1);

$watchlog = new Watchlog('http://watchlog-agent:3774'); // Custom agent URL