PHP code example of cybercog / opentsdb-client

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

    

cybercog / opentsdb-client example snippets


$dataPointList[] = new \Cog\OpenTsdbClient\DataPoint(
    metric: 'temperature',
    timestamp: time(),
    value: -38.04,
    tags: ['place' => 'south_pole'],
);
$dataPointList[] = new \Cog\OpenTsdbClient\DataPoint(
    metric: 'temperature',
    timestamp: time(),
    value: -2.12,
    tags: ['place' => 'north_pole'],
);

$openTsdbClient = new \Cog\OpenTsdbClient\OpenTsdbClient(
    httpClient: \Http\Adapter\Guzzle7\Client::createWithConfig(
        [
            'timeout' => 4,
            'connect_timeout' => 2,
            'http_errors' => false,
        ],
    ),
    baseUri: 'http://opentsdb:4242',
);

$openTsdbClient->sendDataPointList($dataPointList);