1. Go to this page and download the library: Download romainnorberg/datadog-api 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/ */
romainnorberg / datadog-api example snippets
use Romainnorberg\DataDogApi\DataDogApi;
// Using env (DATADOG_API_KEY & DATADOG_APPLICATION_KEY)
$datadogApi = new DataDogApi();
// Using arguments
$datadogApi = new DataDogApi('<apiKey>', '<applicationKey>');
use Romainnorberg\DataDogApi\DataDogApi;
$datadogApi = new DataDogApi(); // Using env
$metrics = $datadogApi
->metrics()
->query()
->from((new \DateTime())->sub(new \DateInterval('PT1H')))
->to(new \DateTime())
->query('avg:worker.memory.heapUsed{*}')
->handle();
use Romainnorberg\DataDogApi\DataDogApi;
$datadogApi = new DataDogApi(); // Using env
$metrics = $datadogApi
...
->query('sum:nginx.net.request_per_s{*}')
->handle();
$max = $metrics->maxPoint();
/**
* Romainnorberg\DataDogApi\Model\Metrics\Point {
+timestamp: 1588269614000
+value: 68.389493934967
}
*/
use Romainnorberg\DataDogApi\DataDogApi;
$datadogApi = new DataDogApi(); // Using env
$metrics = $datadogApi
->downtime()
->list()
//->currentOnly() // Only return downtimes that are active when the request is made.
->handle()
->response();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.