stat-datadog/php-datadog_wrapper

简化版的Datadog PHP封装库

此包的官方仓库似乎已不存在,因此该包已被冻结。

1.0 2016-08-01 17:33 UTC

This package is not auto-updated.

Last update: 2024-02-09 17:02:21 UTC


README

在工作上每天使用它后,我们最终得到了这个结果

使用方法

composer require stat-datadog/php-datadog_wrapper

在config.ini(src/config.ini)中设置datadog api_key。您可以在这里https://app.datadoghq.com/account/settings#api)找到您的API和应用程序密钥。

事件

示例 #1

$event = new \Datadog\Send\Event();


$eventUrl = $client
            ->setEventTitle('test title of the event') //string (REQUIRED)
            ->setEventMessage('message of the EVENT') //string | markdown (REQUIRED)
            ->setEventTime(time())
            ->setEventPriority('low') //normal | low
            ->setEventHost('test.host') // string
            ->setEventTags('tag1, tag2') // comma separated list
            ->setEventAlert_type('info') //"error", "warning", "info" or "success"
            ->setEventSource_type_name('my apps') // nagios, hudson, jenkins, user, my apps, feed, chef, puppet, git, bitbucket, fabric, capistrano
            ->sendEvent();

echo $eventUrl; //url of the event

示例 #2

$client = new Datadog();

$eventArr = array(
    'title' => TITLE, //string (REQUIRED)
    'text' => TEXT, //string | markdown (REQUIRED)
    'date_happened' => timestamp,
    'priority' => PRIORITY, //normal | low
    'host' => HOST, // string
    'tags' => TAGS, // comma separated list
    'alert_type' => ALERT_TYPE, //"error", "warning", "info" or "success"
    'source_type_name' => EVENT TYPE // nagios, hudson, jenkins, user, my apps, feed, chef, puppet, git, bitbucket, fabric, capistrano
);

$eventUrl = $client->eventArr($eventArr); //url of the event

指标

示例 #1

$metric = new \Datadog\Send\Metric();
$metricCheck = $metric->setMetricName('test_metric_name')
    ->setMetricPoints('100, 98, 1470013851-45') // (points-timestamp, points, points, points-timestamp, points, points..., points-timestamp) ## order and length are irrelevant ## use a "timestamp-points" format or not
    ->setMetricHost('test.my.host')
    ->setMetricTags('test:1, test:2, test:4')
    ->sendMetric();

echo $metricCheck; // boolean

示例 #2

$client = new Datadog();

$test1 = array(
        array(20), // datapoint
        array(13456789, 30), // timestamp, datapoint
        array(40) // datapoint
    );

$metricCheck = $client->sendMetric(
    array('test_short.metric',
            'points'=>$test1,
            'host' => 'test_short.my.host',
            'tags' => ['test_short:1', 'test_short:5', 'test_short:7'] // array of strings
    ));

echo $metricCheck; // boolean

####待办

  • 在一次请求中发送指标数组