Statsd
Overview
로그 수집 데몬 statsd 내용 정리
Basic
Statsd datagram
StatsD clients encode metrics into simple, text-based, UDP datagram. Though your client takes care of forming these datagrams.
A StatsD datagram, which contains a single metric, has the following format.
<bucket>:<value>|<type>|@<sample rate>
- Bucket
- The bucket is an identifier for the metric. Metric datagrams with the same bucket and the same type are considered occurrences of the same event by the server.
- Value
- The value is a number that is associated with the metric. Values have different meanings depending on the metric's type.
- Sample rate
The sample rate is used to indicate to the server that the metric was down-sampled. The sampling rate is intended to reduce the number of metric datagrams sent to the StatsD server, since the server's aggregations can get expensive. The sample rate determines what percentage of the metric points a client should send to the server. The server accounts for this sampling by dividing the values it receives by the sample rate. For example, if a metric has a sampling rate of 0.1, only 10 percent of the metrics will be went by the client to the server. The server will then divide the values for these metrics by 0.1 (or multiply by 10) to get an estimate of the true value in the case of additive metrics, such as the login invocation count we used in the example above.
Data Types
statsd 서버는 30초의 간격을 두고 graphite로 데이터를 전송한다. 그리고 graphite 에서는 평균 averaged bucket 에 저장된지 1분이 된 데이터만을 저장하므로, graph 로 나타나는 데이터는 보통 1분이 지난 데이터라고 할 수 있다.
Counters
Counters type 은 가장 기본적인 데이터 타입이다. 지정된 샘플링 시간동안 발생한 지정된 이벤트의 갯수를 나타내는데 사용된다.
예를 들어 샘플링 시간이 10초이고, 10초 동안 발생한 이벤트(지정된 이벤트)의 갯수가 7번이라고 한다면, counters 의 값은 0.7 이 된다.
Timers
Timers are meant to track how long something took. They are an invaluable tool for tracking application performance.
The statsd server collects all timers under stats.timers prefix, and will calculate the lower bound, mean, 90th percentile, upper bound, and count of each timer for each period(by the time you see it in Graphite, that's usually per minute).
- The lower bound is the lowest value statsd saw for that stat during that time period.
- The mean is the average of all values statsd saw for that stat during that time period.
- The 90th percentile is a value x such that 90% of all the values statsd saw for that stat during that time period are below x, and 10% are above. This is a great number to try to optimize.
- The upper bound is the highest value statsd saw for that during that time period.
- The count is the number of timings statsd saw for that stat during that time period. It is not averaged.
Gauges
Gauges are a constant data type. They are not subject to averaging, and they don't change unless you change them. That is, once you set a gauge value, it will be a flat line on the graph until you change it again.
Gauges are useful for things that are already averaged, or don't need to reset periodically. System load, for example, could be graphed with a gauge.
The statsd server collects gauges under the stats.gauges perfix.
Sets
Sets count the number of unique values passed to a key.
If the method is called multiple times with the same value in the same sample period, that value will only be counted once. <source lang=python> c.set('users', 'foo') c.set('users', 'bar') </source>
See also
- https://github.com/etsy/statsd/wiki - statsd official wiki.
- https://tedwon.atlassian.net/wiki/spaces/SE/pages/1213199/StatsD+Graphite+Technical+Analysis+Report+for+Analytics+Purpose - StatsD & Graphite Technical Analysis Report for Analytics Purpose
- http://blog.goguardian.com/nerds/monitoring-applications-with-statsd - Monitoring Applications with StatsD
- https://www.digitalocean.com/community/tutorials/how-to-configure-statsd-to-collect-arbitrary-stats-for-graphite-on-ubuntu-14-04 - How To Configure StatsD to Collect Arbitrary Stats for Graphite on Ubuntu 14.04