1 | # StatsD Metric Types
|
2 |
|
3 | ## Counting
|
4 |
|
5 | gorets:1|c
|
6 |
|
7 | This is a simple counter. Add 1 to the "gorets" bucket.
|
8 | At each flush the current count is sent and reset to 0.
|
9 | If the count at flush is 0 then you can opt to send no metric at all for
|
10 | this counter, by setting `config.deleteCounters` (applies only to graphite
|
11 | backend). 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 |
|
17 | Tells 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 |
|
23 | The glork took 320ms to complete this time. StatsD figures out percentiles,
|
24 | average (mean), standard deviation, sum, lower and upper bounds for the flush interval.
|
25 | The percentile threshold can be tweaked with `config.percentThreshold`.
|
26 |
|
27 | The percentile threshold can be a single value, or a list of values, and will
|
28 | generate 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 |
|
34 | Where `$KEY` is the stats key you specify when sending to statsd, and `$PCT` is
|
35 | the percentile threshold.
|
36 |
|
37 | Note that the `mean` metric is the mean value of all timings recorded during
|
38 | the flush interval whereas `mean_$PCT` is the mean of all timings which fell
|
39 | into the `$PCT` percentile for that flush interval. And the same holds for sum
|
40 | and upper. See [issue #157](https://github.com/etsy/statsd/issues/157) for a
|
41 | more detailed explanation of the calculation.
|
42 |
|
43 | If the count at flush is 0 then you can opt to send no metric at all for this timer,
|
44 | by setting `config.deleteTimers`.
|
45 |
|
46 | Use the `config.histogram` setting to instruct statsd to maintain histograms
|
47 | over time. Specify which metrics to match and a corresponding list of
|
48 | ordered non-inclusive upper limits of bins (class intervals).
|
49 | (use `inf` to denote infinity; a lower limit of 0 is assumed)
|
50 | Each `flushInterval`, statsd will store how many values (absolute frequency)
|
51 | fall within each bin (class interval), for all matching metrics.
|
52 | Examples:
|
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 |
|
66 | Statsd also maintains a counter for each timer metric. The 3rd field
|
67 | specifies the sample rate for this counter (in this example @0.1). The field
|
68 | is optional and defaults to 1.
|
69 |
|
70 | Note:
|
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
|
75 | histograms, as you can make each bin arbitrarily wide,
|
76 | i.e. class intervals of different sizes.
|
77 |
|
78 | ## Gauges
|
79 |
|
80 | StatsD 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 |
|
84 | If the gauge is not updated at the next flush, it will send the previous value. You can opt to send
|
85 | no metric at all for this gauge, by setting `config.deleteGauges`
|
86 |
|
87 | Adding a sign to the gauge value will change the value, rather than setting it.
|
88 |
|
89 | gaugor:-10|g
|
90 | gaugor:+4|g
|
91 |
|
92 | So if `gaugor` was `333`, those commands would set it to `333 - 10 + 4`, or
|
93 | `327`.
|
94 |
|
95 | Note:
|
96 |
|
97 | This implies you can't explicitly set a gauge to a negative number
|
98 | without first setting it to zero.
|
99 |
|
100 | ## Sets
|
101 |
|
102 | StatsD supports counting unique occurences of events between flushes,
|
103 | using a Set to store all occuring events.
|
104 |
|
105 | uniques:765|s
|
106 |
|
107 | If the count at flush is 0 then you can opt to send no metric at all for this set, by
|
108 | setting `config.deleteSets`.
|
109 |
|
110 | ## Multi-Metric Packets
|
111 |
|
112 | StatsD supports receiving multiple metrics in a single packet by separating them
|
113 | with a newline.
|
114 |
|
115 | gorets:1|c\nglork:320|ms\ngaugor:333|g\nuniques:765|s
|
116 |
|
117 | Be careful to keep the total length of the payload within your network's MTU. There
|
118 | is no single good value to use, but here are some guidelines for common network
|
119 | scenarios:
|
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)*
|