首页 > 其他分享 >statsd发送数据类型五种方式

statsd发送数据类型五种方式

时间:2023-04-14 10:01:41浏览次数:40  
标签:statsd metric each value 五种 send flush 发送数据 setting


Counting

gorets:1|c

This is a simple counter. Add 1 to the "gorets" bucket. At each flush the current count is sent and reset to 0. If the count at flush is 0 then you can opt to send no metric at all for this counter, by setting config.deleteCounters (applies only to graphite backend). Statsd will send both the rate as well as the count at each flush.

Sampling

gorets:1|c|@0.1

Tells StatsD that this counter is being sent sampled every 1/10th of the time.

Timing

glork:320|ms|@0.1

The glork took 320ms to complete this time. StatsD figures out percentiles, average (mean), standard deviation, sum, lower and upper bounds for the flush interval. The percentile threshold can be tweaked with config.percentThreshold.

The percentile threshold can be a single value, or a list of values, and will generate the following list of stats for each threshold:

stats.timers.$KEY.mean_$PCT
stats.timers.$KEY.upper_$PCT
stats.timers.$KEY.sum_$PCT

Where $KEY is the stats key you specify when sending to statsd, and $PCT is the percentile threshold.

Note that the mean metric is the mean value of all timings recorded during the flush interval whereas mean_$PCT is the mean of all timings which fell into the $PCT percentile for that flush interval. And the same holds for sum and upper. Seeissue #157 for a more detailed explanation of the calculation.

If the count at flush is 0 then you can opt to send no metric at all for this timer, by setting config.deleteTimers.

Use the config.histogram setting to instruct statsd to maintain histograms over time. Specify which metrics to match and a corresponding list of ordered non-inclusive upper limits of bins (class intervals). (use inf to denote infinity; a lower limit of 0 is assumed) Each flushInterval, statsd will store how many values (absolute frequency) fall within each bin (class interval), for all matching metrics. Examples:

  • no histograms for any timer (default): []
  • histogram to only track render durations, with unequal class intervals and catchall for outliers:
[ { metric: 'render', bins: [ 0.01, 0.1, 1, 10, 'inf'] } ]
  • histogram for all timers except 'foo' related, with equal class interval and catchall for outliers:
[ { metric: 'foo', bins: [] },
    { metric: '', bins: [ 50, 100, 150, 200, 'inf'] } ]

Statsd also maintains a counter for each timer metric. The 3rd field specifies the sample rate for this counter (in this example @0.1). The field is optional and defaults to 1.

Note:

  • first match for a metric wins.
  • bin upper limits may contain decimals.
  • this is actually more powerful than what's strictly considered histograms, as you can make each bin arbitrarily wide, i.e. class intervals of different sizes.

Gauges

StatsD now also supports gauges, arbitrary values, which can be recorded.

gaugor:333|g

If the gauge is not updated at the next flush, it will send the previous value. You can opt to send no metric at all for this gauge, by setting config.deleteGauges

Adding a sign to the gauge value will change the value, rather than setting it.

gaugor:-10|g
gaugor:+4|g

So if gaugor was 333, those commands would set it to 333 - 10 + 4, or 327.

Note:

This implies you can't explicitly set a gauge to a negative number without first setting it to zero.

Sets

StatsD supports counting unique occurences of events between flushes, using a Set to store all occuring events.

uniques:765|s

If the count at flush is 0 then you can opt to send no metric at all for this set, by setting config.deleteSets.

Multi-Metric Packets

StatsD supports receiving multiple metrics in a single packet by separating them with a newline.

gorets:1|c\nglork:320|ms\ngaugor:333|g\nuniques:765|s

Be careful to keep the total length of the payload within your network's MTU. There is no single good value to use, but here are some guidelines for common network scenarios:

  • Fast Ethernet (1432) - This is most likely for Intranets.
  • Gigabit Ethernet (8932) - Jumbo frames can make use of this feature much more efficient.
  • Commodity Internet (512) - If you are routing over the internet a value in this range will be reasonable. You might be able to go higher, but you are at the mercy of all the hops in your route.

(These payload numbers take into account the maximum IP + UDP header sizes)

 

reference:

        https://github.com/etsy/statsd/blob/master/docs/metric_types.md

 

标签:statsd,metric,each,value,五种,send,flush,发送数据,setting
From: https://blog.51cto.com/u_6186189/6189416

相关文章

  • AOP配置(XML)-五种通知类型配置
         ......
  • 在发送数据头部加上内容长度解决TCP 数据粘包
    在学习网络编程socket章节时,发现在客户端向服务器端发送数据时有时可能出现粘包的问题,因此这里记录一下通过添加数据头的方式解决粘包问题。首先什么是数据粘包?其实之所以出现粘包问题,往往是因为网络问题,或者发送端与接收端发送/接收频率不对等引起的因为TCP协议是传......
  • python中列表的删除操作,五种方式
    列表删除操作1、列表删除操作1.1remove()1.2pop()1.3切片1.4clear与del 1、列表删除操作五种方式分别为:remove():一次删除一个元素;如果列表内有重复元素则删除第一个;元素不存在时抛出异常ValueErrorpop():删除一个指定的索引位置上的元素;指定索引不存在则......
  • MRO工业品类型的五种分类
    我们都知道,一个行业需要多种产品来创造理想的结果,这些产品大致分为两类:消费品和工业产品,我们大多数人都知道消费品,因为这些产品是根据我们的个人需求购买的。然而,对MRO工业品产品类型的理解在很大程度上仍是未知数。MRO工业商品或产品是用于企业的商品或产品,通常用于进一步加工,而......
  • 如何用java校验SQL语句的合法性?(提供五种解决方案)
    方案一:使用JDBCAPI中提供的Statement接口的execute()方法要在Java中校验SQL语句的合法性,可以使用JDBCAPI中提供的Statement接口的execute()方法。这个方法会尝试执行给定的SQL语句,如果SQL语句不合法,则会抛出一个SQLException异常。因此,我们可以利用这个异常来判断SQL语句的合法......
  • 进程间的五种通信方式介绍
    进程间通信(IPC,InterProcessCommunication)是指在不同进程之间传播或交换信息。IPC的方式通常有管道(包括无名管道和命名管道)、消息队列、信号量、共享存储、Socket、Streams等。其中Socket和Streams支持不同主机上的两个进程IPC。以Linux中的C语言编程为例。一、管道管道,通常......
  • 【面试专栏】Java创建多线程的五种方式
    1.继承Thread类importlombok.extern.slf4j.Slf4j;importorg.junit.jupiter.api.Test;/***继承Thread类创建多线程单元测试**@authorCL*/@Slf4jpublic......
  • 五种Python中字典的高级用法
    用作switch/case在许多编程语言中,switch/case语句允许大家根据变量的值来执行不同的操作。虽然Python没有内置的switch/case语句,但是大家可以通过使用字典来实现类似的功......
  • java-使用jmh基准测试框架比较五种字符串拼接性能
    java-使用jmh基准测试框架比较五种字符串拼接性能引言Java中提供了5种字符串拼接的方法,使用+拼接字符串是最长见的方法。除此还有StringBuilder、StringBuffer、MessageForm......
  • 五种常用的web安全认证方式
    https://www.oldboyedu.com/blog/4538.html 现如今web服务器随处可见,千万台web程序被部署到公网上供用户访问,有些系统只针对指定用户开放,属于安全级别较高的web应用,他们......