承接 romainnorberg/datadog-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

romainnorberg/datadog-api

最新稳定版本:v0.6

Composer 安装命令:

composer require romainnorberg/datadog-api

包简介

The missing DataDog API PHP Wrapper! A lightweight package to fetch metrics from Datadog

README 文档

README

NON OFFICIAL PACKAGE

Datadog API

Latest Version on Packagist GitHub Tests Action Status codecov Total Downloads

The missing DataDog API PHP Wrapper! A lightweight package to fetch metrics from Datadog

Actual scope

  • Metrics doc

    • ✅ Get active list
    • ✅ Get metadata
    • ✅ Query timeseries points
    • Edit metadata
    • Search
    • Submit metrics
  • Downtimes doc

    • ✅ Get all downtimes
    • Cancel a downtime
    • Cancel downtimes by scope
    • Get a downtime
    • Schedule a downtime
    • Update a downtime

Installation

You can install the package via composer:

composer require romainnorberg/datadog-api

Usage / examples

Instantiation

use Romainnorberg\DataDogApi\DataDogApi;

// Using env (DATADOG_API_KEY & DATADOG_APPLICATION_KEY)
$datadogApi = new DataDogApi();  

// Using arguments
$datadogApi = new DataDogApi('<apiKey>', '<applicationKey>');

Metrics

Fetching metrics

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();

Get max values for a specific period

|----^-------|

Using $metrics->maxPoint() provide the highest point for the requested period.

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
  }
 */

Using $metrics->maxPointBySerie() provide highest points by serie for the requested period. By example if you query by host, you can retrieve max point by host.

use Romainnorberg\DataDogApi\DataDogApi;

$datadogApi = new DataDogApi(); // Using env 

$metrics = $datadogApi
            ...
            ->query('sum:nginx.net.request_per_s{*} by{host}')
            ->handle();

$maxBySerie = $metrics->maxPointBySerie();

/*
 * array:4 [
     0 => array:2 [
       "serie" => Romainnorberg\DataDogApi\Model\Metrics\Serie^ {#292
         +aggr: "sum"
         +end: 1588269659000
         +expression: "sum:nginx.net.request_per_s{host:staging}"
         +interval: 1
         +length: 32
         +metric: "nginx.net.request_per_s"
         +pointlist: []
         +scope: "host:staging"
         +start: 1588269548000
       }
       "point" => array:2 [
         0 => 1588269594000.0
         1 => 1.1333215343856
       ]
     ]
     1 => array:2 [
       "serie" => Romainnorberg\DataDogApi\Model\Metrics\Serie^ {#70
         +aggr: "sum"
         +end: 1588269659000
         +expression: "sum:nginx.net.request_per_s{host:frontend1}"
         +interval: 1
         +length: 32
         +metric: "nginx.net.request_per_s"
         +pointlist: []
         +scope: "host:frontend1"
         +start: 1588269548000
       }
       "point" => array:2 [
         0 => 1588269608000.0
         1 => 51.069667634348
       ]
     ]
     ...
 */

Downtimes

Get all downtimes

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();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email romainnorberg@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 3.98k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固