女子与小人难养也什么意思| 气血亏虚吃什么中成药| 神经衰弱吃什么中成药| 肾功能不好有什么症状| 什么是碳水食物有哪些| 虢是什么意思| 念旧的人是什么样的人| 囟门闭合早有什么影响| 补充微量元素吃什么| 释怀和释然有什么区别| 虚火吃什么药| 黎山老母什么级别神仙| 很容易饿是什么原因| 终身为国是什么生肖| 什么人不适合喝咖啡| 麒麟儿是什么意思| 不知道干什么| 见色起意是什么意思| 倾注是什么意思| 什么的黄瓜| 洲际导弹是什么意思| 申是什么意思| 曲安奈德针治疗什么| 龙凤呈祥是什么生肖| 禅让制是什么意思| 蛇什么时候出来活动| 梦见自己生男孩是什么意思| 五七年属什么生肖| 外科医生是做什么的| 酸奶什么时候喝最好| 痛风吃什么药最好| 三焦不通吃什么中成药| 虎和什么属相不合| 三高可以吃什么水果| 喝枸杞子泡水有什么好处和坏处| 眼睛周围长脂肪粒是什么原因| 拉肚子吃什么药好| 泡沫尿是什么病| 马鞍皮是什么皮| 验孕棒什么时候测| 纤维瘤挂什么科| 唐筛是检查什么的| 红烧排骨用什么排骨比较好| 梦见火是什么意思| 医嘱是什么意思| studio什么牌子| 脂肪肝什么东西不能吃| 6.25什么星座| 鱼子酱为什么那么贵| 掷是什么意思| 薏苡仁是什么| 2035年是什么年| 肠道易激惹综合征的症状是什么| 这是什么病| 荨麻疹吃什么药最管用| 隐翅虫皮炎用什么药| 边界感是什么意思| 2月10日什么星座| 见利忘义是什么意思| 什么食物含叶酸多| 血为什么是红色的| 降钙素原高是什么原因| 老鼠尿是什么颜色的| 赵国是现在的什么地方| 酸碱度偏高是什么意思| 沙漠为什么是三点水| 7月29号是什么星座| 随便你是什么意思| 吸入物变应原筛查是什么| 口酸吃什么药效果好| 心肌酶谱是查什么的| 烤麸是用什么做的| 吃什么可以提高免疫力| 肚子疼吐了是什么原因| 人的五官是什么| 多囊为什么要吃避孕药| 身体年龄是什么意思| 受精卵着床的时候会有什么症状| 呈现是什么意思| 腿麻木是什么原因引起的| 干咳吃什么药效果好| 孕妇羊水多是什么原因造成的| 心脏扩大吃什么药好| 梦见洗车是什么意思| 嘴巴发苦吃什么药| 什么是四环素牙| 刘邦和刘备什么关系| 爬行对身体有什么好处| 三点水加分念什么| 反胃是什么原因引起的| 口红用什么能洗掉| 什么旺土| 笃定什么意思| 十玉九裂是什么意思| bv中间型是什么意思| 这个季节有什么水果| 破月什么意思| 妄想症吃什么药| 吃完紧急避孕药不能吃什么| 欧巴桑什么意思| 为什么不能用红笔写名字| 小壁虎的尾巴有什么作用| 零和博弈是什么意思| 胰岛素抵抗有什么症状| 缺维生素a吃什么食物| 圈癣是什么引起的| avg是什么意思| 头顶疼是什么原因引起的| 宫颈柱状上皮异位是什么意思| 照身份证穿什么衣服| 阳虚什么症状| 阴阳两虚吃什么药最好| 胎停是什么原因造成的| 风湿吃什么药好| 1971年属猪的是什么命| 麻醉对身体有什么伤害| 为什么同房后小腹隐隐作痛| 灵魂摆渡是什么意思| 脚发麻是什么原因| 寒胃有什么症状| 父亲节要送什么礼物好| 二是什么意思| 6月8号什么星座| 腹部b超能检查出什么| mon什么意思| 疖肿是什么意思| 多喝水有什么好处和坏处| 喝什么茶可以降血脂| 湖南有什么景点| 安之若素什么意思| 中阴身是什么意思| 海蓝之谜适合什么年龄| 死亡是什么感觉| 金字旁目字读什么| 贩子是什么意思| 法令纹上的痣代表什么| 神经性皮炎用什么药| 灰色裤子配什么上衣好看| 睡醒嘴巴苦是什么原因| 蒲公英有什么功效| 10月23号是什么星座| 足跟痛挂什么科| 螺旋杆菌是什么病| 反酸吃什么食物好| 牙齿痛吃什么| 血脂高是什么意思| 什么是辛辣食物| 7月生日是什么星座| 被螨虫咬了擦什么药膏| 水煮肉片放什么配菜| 宫颈炎是什么病| 菜粥里面放什么菜最好| 打白条是什么意思| 王玉读什么| 落枕贴什么膏药| 解痉镇痛酊有什么功效| 香蕉可以做什么美食| 金族念什么| 网络维护是做什么的| 能是什么意思| 吃什么水果养胃| 生性凉薄什么意思| amass是什么牌子| 神话故事有什么| 指教是什么意思| 薄荷不能和什么一起吃| 头皮发白是什么原因| 透明的什么| 猫鼻支是什么症状| 挂钟挂在客厅什么位置好| 铜陵有什么好玩的地方| 和可以组什么词| 甲亢什么症状表现| 千钧一发是什么生肖| 喉咙有异物挂什么科| 孩子病毒感染吃什么药| 免贵姓是什么意思| 胃热是什么原因| 通字五行属什么| 玫瑰糠疹用什么药| 什么睡姿对髋关节好| 辣椒炒肉用什么肉| 腰肌劳损用什么药| 顾里为什么和席城睡了| 9月19日是什么星座| 甘霖是什么意思| 县级以上医院是指什么| 打更是什么意思| 指甲分层是什么原因| 舌苔厚发白是什么原因| 速度等于什么| 什么情况下血压会升高| 甲状腺挂什么科| 灰指甲是什么症状| 拉拉裤和纸尿裤有什么区别| 抗锯齿是什么意思| 观音婢是什么意思| 送巧克力代表什么意思| 眼睛疼吃什么药效果最好| 嚷能组什么词| 淋巴细胞百分比高是什么原因| 冲煞是什么意思| 鱼油什么时间吃最好| 共度良宵是什么意思| 尿频尿急是什么症状| 无患子为什么叫鬼见愁| 嘶哑什么意思| 什么是豆粕| 刺梨根泡酒有什么功效| 7月12日是什么星座| 什么奶粉最好| 愿力是什么意思| 抗核抗体弱阳性说明什么| ntl是什么意思| 为什么女生喜欢腹肌| 一字之师是什么意思| 测血型挂什么科| 同房时间短吃什么药| cosplay什么意思| 什么情况下吃救心丸| 地贫吃什么补血最快| rover是什么意思| 什么是电解质饮料| 脸上突然长斑是什么原因引起的| 什么空调省电| 温暖如初是什么意思| 物化是什么意思| 吃什么可以补血| sansui是什么牌子| 4月2号是什么星座| 次方是什么意思| 初级中学是什么意思| 白色代表什么| 10月是什么月| 醉酒当歌什么意思| hpv什么病| 细菌感染是什么原因| 什么血型的人最多| 花甲不能和什么一起吃| 皮肤过敏不能吃什么食物| 冰箱里有什么细菌| 做生意的人最忌讳什么| 什么是单核细胞百分比| 十二月份的是什么星座| 宫颈管是什么| 拉肚子吃什么水果| 禅茶一味什么意思| 社保断了有什么影响| 前位子宫是什么意思| 心五行属性是什么| 肝内小钙化灶是什么意思| 献出什么| 膀胱在什么位置图片| 身上到处痒是什么原因| 什么是阳痿| 经期延长是什么原因引起的| 5月8号是什么星座| 栓塞是什么意思| 总胆固醇什么意思| 绝代双骄是什么意思| 2001年出生属什么| 木耳属于什么类| 八卦中代表雷的卦象叫什么| 黄油可以做什么美食| 百度

食药监总局:224批次被抽检婴幼儿奶粉全部合格

百度   紫光阁网站是中央国家机关工作委员会主办的,以宣传中央国家机关党的建设为主的综合性网站。

While StatsD accepts only metrics, DogStatsD accepts all three of the major Datadog data types: metrics, events, and service checks. This section shows typical use cases for metrics split down by metric types, and introduces sampling rates and metric tagging options specific to DogStatsD.

COUNT, GAUGE, and SET metric types are familiar to StatsD users. TIMER from StatsD is a sub-set of HISTOGRAM in DogStatsD. Additionally, you can submit HISTOGRAM and DISTRIBUTION metric types using DogStatsD.

Note: Depending on the submission method used, the actual metric type stored within Datadog might differ from the submission metric type. When submitting a RATE metric type through DogStatsD, the metric appears as a GAUGE in-app to ensure relevant comparison across different Agents.

Functions

After you install DogStatsD, the following functions are available for submitting your metrics to Datadog depending on their metric type. The functions have the following shared parameters:

ParameterTypeRequiredDescription
<METRIC_NAME>StringYesName of the metric to submit.
<METRIC_VALUE>DoubleYesValue associated with your metric.
<SAMPLE_RATE>DoubleNoThe sample rate to apply to the metric. Takes a value between 0 (everything is sampled, so nothing is sent) and 1 (no sample). See the Sample Rate section to learn more.
<TAGS>List of stringsNoA list of tags to apply to the metric. See the Metrics Tagging section to learn more.

COUNT

increment(<METRIC_NAME>, <SAMPLE_RATE>, <TAGS>)
Used to increment a COUNT metric. Stored as a RATE type in Datadog. Each value in the stored timeseries is a time-normalized delta of the metric’s value over the StatsD flush period.
decrement(<METRIC_NAME>, <SAMPLE_RATE>, <TAGS>)
Used to decrement a COUNT metric. Stored as a RATE type in Datadog. Each value in the stored timeseries is a time-normalized delta of the metric’s value over the StatsD flush period.
count(<METRIC_NAME>, <METRIC_VALUE>, <SAMPLE_RATE>, <TAGS>)
Used to increment a COUNT metric from an arbitrary Value. Stored as a RATE type in Datadog. Each value in the stored timeseries is a time-normalized delta of the metric’s value over the StatsD flush period.

Note: COUNT type metrics can show a decimal value within Datadog since they are normalized over the flush interval to report per-second units.

Code examples

Emit a COUNT metric-stored as a RATE metric-to Datadog. Learn more about the COUNT type in the metric types documentation.

Run the following code to submit a DogStatsD COUNT metric to Datadog. Remember to flush/close the client when it is no longer needed.

from datadog import initialize, statsd
import time

options = {
    'statsd_host':'127.0.0.1',
    'statsd_port':8125
}

initialize(**options)

while(1):
  statsd.increment('example_metric.increment', tags=["environment:dev"])
  statsd.decrement('example_metric.decrement', tags=["environment:dev"])
  time.sleep(10)

Note: statsd.count is not supported in Python.

require 'datadog/statsd'

statsd = Datadog::Statsd.new('localhost', 8125, tags: ['environment:dev'])

while true do
    statsd.increment('example_metric.increment')
    statsd.increment('example_metric.increment', tags: ['another:tag'])
    statsd.decrement('example_metric.decrement')
    statsd.count('example_metric.count', 2)
    sleep 10
end
package main

import (
	"log"
	"time"

	"github.com/DataDog/datadog-go/statsd"
)

func main() {
	statsd, err := statsd.New("127.0.0.1:8125")
	if err != nil {
		log.Fatal(err)
	}
	for true {

		statsd.Incr("example_metric.increment", []string{"environment:dev"}, 1)
		statsd.Decr("example_metric.decrement", []string{"environment:dev"}, 1)
		statsd.Count("example_metric.count", 2, []string{"environment:dev"}, 1)
		time.Sleep(10 * time.Second)
	}
}
import com.timgroup.statsd.NonBlockingStatsDClientBuilder;
import com.timgroup.statsd.StatsDClient;
import java.util.Random;

public class DogStatsdClient {

    public static void main(String[] args) throws Exception {

        StatsDClient Statsd = new NonBlockingStatsDClientBuilder()
            .prefix("statsd")
            .hostname("localhost")
            .port(8125)
            .build();
        while (true) {
            Statsd.incrementCounter("example_metric.increment", new String[]{"environment:dev"});
            Statsd.decrementCounter("example_metric.decrement", new String[]{"environment:dev"});
            Statsd.count("example_metric.count", 2, new String[]{"environment:dev"});
            Thread.sleep(100000);
        }
    }
}
using StatsdClient;
using System;

public class DogStatsdClient
{
    public static void Main()
    {
        var dogstatsdConfig = new StatsdConfig
        {
            StatsdServerName = "127.0.0.1",
            StatsdPort = 8125,
        };

        using (var dogStatsdService = new DogStatsdService())
        {
            if (!dogStatsdService.Configure(dogstatsdConfig))
                throw new InvalidOperationException("Cannot initialize DogstatsD. Set optionalExceptionHandler argument in the `Configure` method for more information.");
            var random = new Random(0);

            while (true)
            {
                dogStatsdService.Increment("example_metric.increment", tags: new[] {"environment:dev"});
                dogStatsdService.Decrement("example_metric.decrement", tags: new[] {"environment:dev"});
                dogStatsdService.Counter("example_metric.count", 2, tags: new[] {"environment:dev"});
                System.Threading.Thread.Sleep(random.Next(100000));
            }
        }
    }
}
<?php

require __DIR__ . '/vendor/autoload.php';

use DataDog\DogStatsd;

$statsd = new DogStatsd(
    array('host' => '127.0.0.1',
          'port' => 8125,
     )
  );

while (TRUE) {
    $statsd->increment('example_metric.increment', 1, array('environment'=>'dev'));
    $statsd->decrement('example_metric.decrement', 1, array('environment'=>'dev'));
    sleep(10);
}
const tracer = require('dd-trace');
tracer.init();

tracer.dogstatsd.increment('example_metric.increment', 1, { environment: 'dev' });
tracer.dogstatsd.decrement('example_metric.decrement', 1, { environment: 'dev' });

After running the code above, your metrics data is available to graph in Datadog:

Increment Decrement

Since the value is submitted as a COUNT it’s stored as RATE in Datadog. To get raw counts within Datadog, apply a function to your series such as the Cumulative Sum or Integral function:

Increment Decrement with Cumsum

GAUGE

gauge(<METRIC_NAME>, <METRIC_VALUE>, <SAMPLE_RATE>, <TAGS>)
Stored as a GAUGE type in Datadog. Each value in the stored timeseries is the last gauge value submitted for the metric during the StatsD flush period.

Code examples

Emit a GAUGE metric-stored as a GAUGE metric-to Datadog. Learn more about the GAUGE type in the metric types documentation.

Run the following code to submit a DogStatsD GAUGE metric to Datadog. Remember to flush/close the client when it is no longer needed.

Note: Metrics submission calls are asynchronous. If you want to ensure metrics are submitted, call flush before the program exits.

from datadog import initialize, statsd
import time

options = {
    'statsd_host':'127.0.0.1',
    'statsd_port':8125
}

initialize(**options)

i = 0

while(1):
  i += 1
  statsd.gauge('example_metric.gauge', i, tags=["environment:dev"])
  time.sleep(10)
require 'datadog/statsd'

statsd = Datadog::Statsd.new('localhost', 8125)

i = 0

while true do
    i += 1
    statsd.gauge('example_metric.gauge', i, tags: ['environment:dev'])
    sleep 10
end
package main

import (
	"log"
	"time"

	"github.com/DataDog/datadog-go/statsd"
)

func main() {
	statsd, err := statsd.New("127.0.0.1:8125")
	if err != nil {
		log.Fatal(err)
	}
	var i float64
	for true {
		i += 1
		statsd.Gauge("example_metric.gauge", i, []string{"environment:dev"}, 1)
		time.Sleep(10 * time.Second)
	}
}
import com.timgroup.statsd.NonBlockingStatsDClientBuilder;
import com.timgroup.statsd.StatsDClient;
import java.util.Random;

public class DogStatsdClient {

    public static void main(String[] args) throws Exception {

        StatsDClient Statsd = new NonBlockingStatsDClientBuilder()
            .prefix("statsd").
            .hostname("localhost")
            .port(8125)
            .build();
        for (int i = 0; true; i++) {
            Statsd.recordGaugeValue("example_metric.gauge", i, new String[]{"environment:dev"});
            Thread.sleep(10000);
        }
    }
}
using StatsdClient;
using System;

public class DogStatsdClient
{
    public static void Main()
    {
        var dogstatsdConfig = new StatsdConfig
        {
            StatsdServerName = "127.0.0.1",
            StatsdPort = 8125,
        };

        using (var dogStatsdService = new DogStatsdService())
        {
            if (!dogStatsdService.Configure(dogstatsdConfig))
                throw new InvalidOperationException("Cannot initialize DogstatsD. Set optionalExceptionHandler argument in the `Configure` method for more information.");
            var random = new Random(0);

            for (int i = 0; true; i++)
            {
                dogStatsdService.Gauge("example_metric.gauge", i, tags: new[] {"environment:dev"});
                System.Threading.Thread.Sleep(100000);
            }
        }
    }
}
<?php

require __DIR__ . '/vendor/autoload.php';

use DataDog\DogStatsd;

$statsd = new DogStatsd(
    array('host' => '127.0.0.1',
          'port' => 8125,
     )
  );

$i = 0;
while (TRUE) {
    $i++;
    $statsd->gauge('example_metric.gauge', $i, array('environment'=>'dev'));
    sleep(10);
}
const tracer = require('dd-trace');
tracer.init();

let i = 0;
while(true) {
  i++;
  tracer.dogstatsd.gauge('example_metric.gauge', i, { environment: 'dev' });
}

After running the code above, your metric data is available to graph in Datadog:

Gauge

SET

set(<METRIC_NAME>, <METRIC_VALUE>, <SAMPLE_RATE>, <TAGS>)
Stored as a GAUGE type in Datadog. Each value in the stored timeseries is the count of unique values submitted to StatsD for a metric over the flush period.

Code examples

Emit a SET metric-stored as a GAUGE metric-to Datadog.

Run the following code to submit a DogStatsD SET metric to Datadog. Remember to flush/close the client when it is no longer needed.

from datadog import initialize, statsd
import time
import random

options = {
    'statsd_host':'127.0.0.1',
    'statsd_port':8125
}

initialize(**options)
i = 0
while(1):
  i += 1
  statsd.set('example_metric.set', i, tags=["environment:dev"])
  time.sleep(random.randint(0, 10))
require 'datadog/statsd'

statsd = Datadog::Statsd.new('localhost', 8125)

i = 0
while true do
    i += 1
    statsd.set('example_metric.gauge', i, tags: ['environment:dev'])
    sleep rand 10
end
package main

import (
	"fmt"
	"log"
	"math/rand"
	"time"

	"github.com/DataDog/datadog-go/statsd"
)

func main() {
	statsd, err := statsd.New("127.0.0.1:8125")
	if err != nil {
		log.Fatal(err)
	}
	var i float64
	for true {
		i += 1
		statsd.Set("example_metric.set", fmt.Sprintf("%f", i), []string{"environment:dev"}, 1)
		time.Sleep(time.Duration(rand.Intn(10)) * time.Second)
	}
}
import com.timgroup.statsd.NonBlockingStatsDClientBuilder;
import com.timgroup.statsd.StatsDClient;
import java.util.Random;

public class DogStatsdClient {

    public static void main(String[] args) throws Exception {

        StatsDClient Statsd = new NonBlockingStatsDClientBuilder()
            .prefix("statsd").
            .hostname("localhost")
            .port(8125)
            .build();
        for (int i = 0; true; i++) {
            Statsd.recordSetValue("example_metric.set", i, new String[]{"environment:dev"});
            Thread.sleep(random.NextInt(10000));
        }
    }
}
using StatsdClient;
using System;

public class DogStatsdClient
{
    public static void Main()
    {
        var dogstatsdConfig = new StatsdConfig
        {
            StatsdServerName = "127.0.0.1",
            StatsdPort = 8125,
        };

        using (var dogStatsdService = new DogStatsdService())
        {
            if (!dogStatsdService.Configure(dogstatsdConfig))
                throw new InvalidOperationException("Cannot initialize DogstatsD. Set optionalExceptionHandler argument in the `Configure` method for more information.");
            var random = new Random(0);

            for (int i = 0; true; i++)
            {
                dogStatsdService.Set("example_metric.set", i, tags: new[] {"environment:dev"});
                System.Threading.Thread.Sleep(random.Next(100000));
            }
        }
    }
}
<?php

require __DIR__ . '/vendor/autoload.php';

use DataDog\DogStatsd;

$statsd = new DogStatsd(
    array('host' => '127.0.0.1',
          'port' => 8125,
     )
  );

$i = 0;

while (TRUE) {
    $i++;
    $statsd->set('example_metric.set', $i, array('environment'=>'dev'));
    sleep(rand(0, 10));
}

After running the code above, your metrics data is available to graph in Datadog:

Set

HISTOGRAM

histogram(<METRIC_NAME>, <METRIC_VALUE>, <SAMPLE_RATE>, <TAGS>)
Since multiple metrics are submitted, metric types stored (GAUGE, RATE) depend on the metric. See the HISTOGRAM metric type documentation to learn more.

Configuration

  • Configure the aggregation to send to Datadog with the histogram_aggregates parameter in your datadog.yaml configuration file. By default, only max, median, avg, and count aggregations are sent.
  • Configure the percentile aggregation to send to Datadog with the histogram_percentiles parameter in your datadog.yaml configuration file. By default, only 95pc percentile is sent.

Code examples

The HISTOGRAM metric type is specific to DogStatsD. Emit a HISTOGRAM metric—stored as a GAUGE and RATE metric—to Datadog. Learn more about the HISTOGRAM type in the metric types documentation.

Run the following code to submit a DogStatsD HISTOGRAM metric to Datadog. Remember to flush/close the client when it is no longer needed.

from datadog import initialize, statsd
import time
import random

options = {
    'statsd_host':'127.0.0.1',
    'statsd_port':8125
}

initialize(**options)

while(1):
  statsd.histogram('example_metric.histogram', random.randint(0, 20), tags=["environment:dev"])
  time.sleep(2)
require 'datadog/statsd'

statsd = Datadog::Statsd.new('localhost', 8125)

while true do
    statsd.histogram('example_metric.histogram', rand 20, tags: ['environment:dev'])
    sleep 2
end
package main

import (
	"log"
	"math/rand"
	"time"

	"github.com/DataDog/datadog-go/statsd"
)

func main() {
	statsd, err := statsd.New("127.0.0.1:8125")
	if err != nil {
		log.Fatal(err)
	}

	for true {
		statsd.Histogram("example_metric.histogram", float64(rand.Intn(20)), []string{"environment:dev"}, 1)
		time.Sleep(2 * time.Second)
	}
}
import com.timgroup.statsd.NonBlockingStatsDClientBuilder;
import com.timgroup.statsd.StatsDClient;
import java.util.Random;

public class DogStatsdClient {

    public static void main(String[] args) throws Exception {

        StatsDClient Statsd = new NonBlockingStatsDClientBuilder()
            .prefix("statsd").
            .hostname("localhost")
            .port(8125)
            .build();
        while (true) {
            Statsd.recordHistogramValue("example_metric.histogram", new Random().nextInt(20), new String[]{"environment:dev"});
            Thread.sleep(2000);
        }
    }
}
using StatsdClient;
using System;

public class DogStatsdClient
{
    public static void Main()
    {
        var dogstatsdConfig = new StatsdConfig
        {
            StatsdServerName = "127.0.0.1",
            StatsdPort = 8125,
        };

        using (var dogStatsdService = new DogStatsdService())
        {
            if (!dogStatsdService.Configure(dogstatsdConfig))
                throw new InvalidOperationException("Cannot initialize DogstatsD. Set optionalExceptionHandler argument in the `Configure` method for more information.");
            var random = new Random(0);

            while (true)
            {
                dogStatsdService.Histogram("example_metric.histogram", random.Next(20), tags: new[] {"environment:dev"});
                System.Threading.Thread.Sleep(2000);
            }
        }
    }
}
<?php

require __DIR__ . '/vendor/autoload.php';

use DataDog\DogStatsd;

$statsd = new DogStatsd(
    array('host' => '127.0.0.1',
          'port' => 8125,
     )
  );

while (TRUE) {
    $statsd->histogram('example_metric.histogram', rand(0, 20), array('environment'=>'dev'));
    sleep(2);
}

The above instrumentation produces the following metrics:

MetricDescription
example_metric.histogram.countNumber of times this metric was sampled
example_metric.histogram.avgAverage of the sampled values
example_metric.histogram.medianMedian sampled value
example_metric.histogram.maxMaximum sampled value
example_metric.histogram.95percentile95th percentile sampled value

After running the code above, your metrics data is available to graph in Datadog:

Histogram

TIMER

TIMER metric type in DogStatsD is an implementation of HISTOGRAM metric type (not to be confused with timers in the standard StatsD). It measures timing data only: for example, the amount of time a section of code takes to execute.

timed(<METRIC_NAME>, <METRIC_VALUE>, <SAMPLE_RATE>, <TAGS>)
Since multiple metrics are submitted, metric types stored (GAUGE, RATE) depend on the metric. See the HISTOGRAM metric type documentation to learn more.
Configuration

For a TIMER, the HISTOGRAM configuration rules apply.

Code examples

Emit a TIMER metric—stored as a GAUGE and RATE metric—to Datadog. Learn more about the HISTOGRAM type in the metric types documentation. Remember to flush/close the client when it is no longer needed.

In Python, timers are created with a decorator.

from datadog import initialize, statsd
import time
import random

options = {
    'statsd_host':'127.0.0.1',
    'statsd_port':8125
}

initialize(**options)

@statsd.timed('example_metric.timer', tags=["environment:dev,function:my_function"])
def my_function():
  time.sleep(random.randint(0, 10))

while(1):
  my_function()

or with a context manager:

from datadog import statsd
import time
import random

def my_function():

  # First some stuff you don't want to time
  sleep(1)

  # Now start the timer
  with statsd.timed('example_metric.timer', tags=["environment:dev"]):
    # do something to be measured
    sleep(random.randint(0, 10))

while(1):
  my_function()
<?php

require __DIR__ . '/vendor/autoload.php';

use DataDog\DogStatsd;

$statsd = new DogStatsd(
    array('host' => '127.0.0.1',
          'port' => 8125,
     )
  );

function runfunction() {
    sleep(rand(0, 20));
}

while (TRUE) {
  $start_time = microtime(TRUE);
  runfunction();
  $statsd->microtiming('example_metric.timer', microtime(TRUE) - $start_time);
}

As DogStatsD receives the timer metric data, it calculates the statistical distribution of render times and sends the following metrics to Datadog:

MetricDescription
example_metric.timer.countNumber of times this metric was sampled
example_metric.timer.avgAverage time of the sampled values
example_metric.timer.medianMedian sampled value
example_metric.timer.maxMaximum sampled value
example_metric.timer.95percentile95th percentile sampled value

DogStatsD treats TIMER as a HISTOGRAM metric. Whether you use the TIMER or HISTOGRAM metric type, you are sending the same data to Datadog. After running the code above, your metrics data is available to graph in Datadog:

Timer

DISTRIBUTION

distribution(<METRIC_NAME>, <METRIC_VALUE>, <TAGS>)
Stored as a DISTRIBUTION type in Datadog. See the dedicated Distribution documentation to learn more.

Code examples

The DISTRIBUTION metric type is specific to DogStatsD. Emit a DISTRIBUTION metric-stored as a DISTRIBUTION metric-to Datadog. Learn more about the DISTRIBUTION type in the metric types documentation.

Run the following code to submit a DogStatsD DISTRIBUTION metric to Datadog. Remember to flush/close the client when it is no longer needed.

from datadog import initialize, statsd
import time
import random

options = {
    'statsd_host':'127.0.0.1',
    'statsd_port':8125
}

initialize(**options)

while(1):
  statsd.distribution('example_metric.distribution', random.randint(0, 20), tags=["environment:dev"])
  time.sleep(2)
require 'datadog/statsd'

statsd = Datadog::Statsd.new('localhost', 8125)

while true do
    statsd.distribution('example_metric.gauge', rand 20, tags: ['environment:dev'])
    sleep 2
end
package main

import (
	"log"
	"math/rand"
	"time"

	"github.com/DataDog/datadog-go/statsd"
)

func main() {
	statsd, err := statsd.New("127.0.0.1:8125")
	if err != nil {
		log.Fatal(err)
	}

	for true {
		statsd.Distribution("example_metric.distribution", float64(rand.Intn(20)), []string{"environment:dev"}, 1)
		time.Sleep(2 * time.Second)
	}
}
import com.timgroup.statsd.NonBlockingStatsDClientBuilder;
import com.timgroup.statsd.StatsDClient;
import java.util.Random;

public class DogStatsdClient {

    public static void main(String[] args) throws Exception {

        StatsDClient Statsd = new NonBlockingStatsDClientBuilder()
            .prefix("statsd").
            .hostname("localhost")
            .port(8125)
            .build();
        while (true) {
            Statsd.recordDistributionValue("example_metric.distribution", new Random().nextInt(20), new String[]{"environment:dev"});
            Thread.sleep(2000);
        }
    }
}
using StatsdClient;
using System;

public class DogStatsdClient
{
    public static void Main()
    {
        var dogstatsdConfig = new StatsdConfig
        {
            StatsdServerName = "127.0.0.1",
            StatsdPort = 8125,
        };

        using (var dogStatsdService = new DogStatsdService())
        {
            if (!dogStatsdService.Configure(dogstatsdConfig))
                throw new InvalidOperationException("Cannot initialize DogstatsD. Set optionalExceptionHandler argument in the `Configure` method for more information.");
            var random = new Random(0);

            while (true)
            {
                dogStatsdService.Distribution("example_metric.distribution", random.Next(20), tags: new[] {"environment:dev"});
                System.Threading.Thread.Sleep(2000);
            }
        }
    }
}
<?php

require __DIR__ . '/vendor/autoload.php';

use DataDog\DogStatsd;

$statsd = new DogStatsd(
    array('host' => '127.0.0.1',
          'port' => 8125,
     )
  );

while (TRUE) {
    $statsd->distribution('example_metric.distribution', rand(0, 20), array('environment'=>'dev'));
    sleep(2);
}
const tracer = require('dd-trace');
tracer.init();

while(true) {
  tracer.dogstatsd.distribution('example_metric.distribution', Math.random() * 20, { environment: 'dev' });
  await new Promise(r => setTimeout(r, 2000));
}

The above instrumentation calculates the sum, count, average, minimum, maximum, 50th percentile (median), 75th percentile, 90th percentile, 95th percentile and 99th percentile. Distributions can be used to measure the distribution of any type of value, such as the size of uploaded files, or classroom test scores.

Metric submission options

Sample rates

Since the overhead of sending UDP packets can be too great for some performance intensive code paths, DogStatsD clients support sampling (only sending metrics a percentage of the time). It’s useful if you sample many metrics, and your DogStatsD client is not on the same host as the DogStatsD server. The trade off: you decrease traffic but lose some precision and granularity.

A sample rate of 1 sends metrics 100% of the time, while a sample rate of 0 sends metrics 0% of the time.

Before sending a metric to Datadog, DogStatsD uses the <SAMPLE_RATE> to correct the metric value depending on the metric type (to estimate the value without sampling):

Metric TypeSample rate correction
COUNTValues received are multiplied by (1/<SAMPLE_RATE>). It’s reasonable to assume that for one datapoint received, 1/<SAMPLE_RATE> were actually sampled with the same value.
GAUGENo correction. The value received is kept as is.
SETNo correction. The value received is kept as is.
HISTOGRAMThe histogram.count statistic is a COUNT metric, and receives the correction outlined above. Other statistics are gauge metrics and aren’t “corrected”.
DISTRIBUTIONValues received are counted (1/<SAMPLE_RATE>) times. It’s reasonable to assume that for one datapoint received, 1/<SAMPLE_RATE> were actually sampled with the same value.

Code examples

The following code only sends points half of the time:

statsd.increment('loop.count', sample_rate=0.5)
statsd.increment('loop.count', :sample_rate => 0.5)
statsd.Incr("example_metric.increment", []string{}, 0.5)
Statsd.incrementCounter("example_metric.increment", sampleRate=0.5);
dogStatsdService.Increment("example_metric.increment", sampleRate: 0.5);
<? php
$statsd->increment('example_metric.increment', $sampleRate->0.5);

Metric tagging

Add tags to any metric you send to DogStatsD with the tags parameter.

Code examples

The following code only adds the environment:dev and account:local tags to the example_metric.increment metric:

statsd.increment('example_metric.increment', tags=["environment:dev","account:local"])
statsd.increment('example_metric.increment', tags: ['environment:dev','account:local'])
statsd.Incr("example_metric.increment", []string{"environment:dev","account:local"}, 1)
Statsd.incrementCounter("example_metric.increment", new String[]{"environment:dev","account:local"});
dogStatsdService.Increment("example_metric.increment", tags: new[] {"environment:dev","account:local"})

The tags argument can be a string:

$statsd->increment('example_metric.increment', "environment:dev,account:local");

or an array:

<?php
$statsd->increment('example_metric.increment', array('environment' => 'dev', 'account' => 'local'));
tracer.dogstatsd.increment('example_metric.increment', 1, { environment: 'dev', account: 'local' });

Host tag

The host tag is assigned automatically by the Datadog Agent aggregating the metrics. Metrics submitted with a host tag not matching the Agent hostname lose reference to the original host. The submitted host tag overrides any hostname collected by or configured in the Agent.

Further reading

Additional helpful documentation, links, and articles:

八九不离十是什么意思 5月8日什么星座 微信上面有个耳朵是什么意思 陀飞轮是什么意思 低级别上皮内瘤变是什么意思
菌子不能和什么一起吃 人怕冷是什么原因引起的 微信什么时候推出的 hpv16阳性有什么症状 什么寒什么暖
2023年属兔的是什么命 玉的五行属性是什么 滇红茶属于什么茶 什么什么的草地 大生化是检查什么
乔迁送什么花 单立人加吉念什么 物竞天择是什么意思 甲亢有什么症状 疣体是什么
yp是什么hcv7jop5ns0r.cn 陈皮有什么作用cl108k.com 湿疹是什么原因造成的hcv9jop4ns5r.cn 天然呆是什么意思hcv8jop3ns2r.cn 喊麦什么意思hcv7jop5ns1r.cn
忐忑什么意思sanhestory.com 怀孕皮肤变差什么原因hcv8jop0ns7r.cn 头晕是什么病的前兆hcv9jop2ns8r.cn 梦见生孩子是什么意思adwl56.com 斛什么意思hcv9jop4ns2r.cn
什么是规培生hcv9jop5ns0r.cn 闺蜜是什么hcv9jop1ns7r.cn 胃下垂是什么症状hcv9jop6ns1r.cn 肝脏不好吃什么食物才能养肝护肝hcv8jop2ns2r.cn 梦见父亲死了是什么意思hcv9jop6ns3r.cn
莼菜是什么菜hcv9jop6ns6r.cn 10年是什么年travellingsim.com ab型血为什么叫贵族血hcv9jop5ns4r.cn 乳房发烫胀痛什么原因qingzhougame.com 太史慈姓什么hcv8jop1ns3r.cn
百度