UNPKG

4.55 kBMarkdownView Raw
1# StatsD Metric Types
2
3## Counting
4
5 gorets:1|c
6
7This is a simple counter. Add 1 to the "gorets" bucket.
8At each flush the current count is sent and reset to 0.
9If the count at flush is 0 then you can opt to send no metric at all for
10this counter, by setting `config.deleteCounters` (applies only to graphite
11backend). Statsd will send both the rate as well as the count at each flush.
12
13## Sampling
14
15 gorets:1|c|@0.1
16
17Tells StatsD that this counter is being sent sampled every 1/10th of the time.
18
19## Timing
20
21 glork:320|ms|@0.1
22
23The glork took 320ms to complete this time. StatsD figures out percentiles,
24average (mean), standard deviation, sum, lower and upper bounds for the flush interval.
25The percentile threshold can be tweaked with `config.percentThreshold`.
26
27The percentile threshold can be a single value, or a list of values, and will
28generate the following list of stats for each threshold:
29
30 stats.timers.$KEY.mean_$PCT
31 stats.timers.$KEY.upper_$PCT
32 stats.timers.$KEY.sum_$PCT
33
34Where `$KEY` is the stats key you specify when sending to statsd, and `$PCT` is
35the percentile threshold.
36
37Note that the `mean` metric is the mean value of all timings recorded during
38the flush interval whereas `mean_$PCT` is the mean of all timings which fell
39into the `$PCT` percentile for that flush interval. And the same holds for sum
40and upper. See [issue #157](https://github.com/etsy/statsd/issues/157) for a
41more detailed explanation of the calculation.
42
43If the count at flush is 0 then you can opt to send no metric at all for this timer,
44by setting `config.deleteTimers`.
45
46Use the `config.histogram` setting to instruct statsd to maintain histograms
47over time. Specify which metrics to match and a corresponding list of
48ordered non-inclusive upper limits of bins (class intervals).
49(use `inf` to denote infinity; a lower limit of 0 is assumed)
50Each `flushInterval`, statsd will store how many values (absolute frequency)
51fall within each bin (class interval), for all matching metrics.
52Examples:
53
54* no histograms for any timer (default): `[]`
55* histogram to only track render durations,
56 with unequal class intervals and catchall for outliers:
57
58 [ { metric: 'render', bins: [ 0.01, 0.1, 1, 10, 'inf'] } ]
59
60* histogram for all timers except 'foo' related,
61 with equal class interval and catchall for outliers:
62
63 [ { metric: 'foo', bins: [] },
64 { metric: '', bins: [ 50, 100, 150, 200, 'inf'] } ]
65
66Statsd also maintains a counter for each timer metric. The 3rd field
67specifies the sample rate for this counter (in this example @0.1). The field
68is optional and defaults to 1.
69
70Note:
71
72* first match for a metric wins.
73* bin upper limits may contain decimals.
74* this is actually more powerful than what's strictly considered
75histograms, as you can make each bin arbitrarily wide,
76i.e. class intervals of different sizes.
77
78## Gauges
79
80StatsD also supports gauges. A gauge will take on the arbitrary value assigned to it, and will maintain it's value until it is next set.
81
82 gaugor:333|g
83
84If the gauge is not updated at the next flush, it will send the previous value. You can opt to send
85no metric at all for this gauge, by setting `config.deleteGauges`
86
87Adding a sign to the gauge value will change the value, rather than setting it.
88
89 gaugor:-10|g
90 gaugor:+4|g
91
92So if `gaugor` was `333`, those commands would set it to `333 - 10 + 4`, or
93`327`.
94
95Note:
96
97This implies you can't explicitly set a gauge to a negative number
98without first setting it to zero.
99
100## Sets
101
102StatsD supports counting unique occurences of events between flushes,
103using a Set to store all occuring events.
104
105 uniques:765|s
106
107If the count at flush is 0 then you can opt to send no metric at all for this set, by
108setting `config.deleteSets`.
109
110## Multi-Metric Packets
111
112StatsD supports receiving multiple metrics in a single packet by separating them
113with a newline.
114
115 gorets:1|c\nglork:320|ms\ngaugor:333|g\nuniques:765|s
116
117Be careful to keep the total length of the payload within your network's MTU. There
118is no single good value to use, but here are some guidelines for common network
119scenarios:
120
121* Fast Ethernet (1432) - This is most likely for Intranets.
122* Gigabit Ethernet (8932) - Jumbo frames can make use of this feature much more
123 efficient.
124* Commodity Internet (512) - If you are routing over the internet a value in this
125 range will be reasonable. You might be able to go higher, but you are at the mercy
126 of all the hops in your route.
127
128*(These payload numbers take into account the maximum IP + UDP header sizes)*