• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Jul-2019-

pkg/H18-Jul-2019-3,5442,756

.editorconfigH A D18-Jul-2019361 2317

.gitignoreH A D18-Jul-2019124 109

.travis.ymlH A D18-Jul-20191.3 KiB4030

CHANGELOG.mdH A D18-Jul-201911.1 KiB431349

LICENSEH A D18-Jul-20191.1 KiB2621

METRICS.mdH A D18-Jul-20197.7 KiB8370

MakefileH A D18-Jul-20195.2 KiB176137

README.mdH A D18-Jul-20197.8 KiB211154

backend.goH A D18-Jul-20191.1 KiB3416

cloudprovider.goH A D18-Jul-20191,002 3317

counters.goH A D18-Jul-20191.4 KiB4831

cover.shH A D18-Jul-2019922 3624

events.goH A D18-Jul-20192.1 KiB9966

gauges.goH A D18-Jul-20191.3 KiB4730

glide.lockH A D18-Jul-20194.3 KiB153152

glide.yamlH A D18-Jul-2019654 2928

metrics.goH A D18-Jul-20193 KiB11892

percentiles.goH A D18-Jul-2019774 3624

sets.goH A D18-Jul-20191.2 KiB4730

tags.goH A D18-Jul-20191.6 KiB5531

timers.goH A D18-Jul-20193.4 KiB10179

types.goH A D18-Jul-2019772 3322

README.md

1gostatsd
2========
3
4[![Godoc](https://godoc.org/github.com/atlassian/gostatsd?status.svg)](https://godoc.org/github.com/atlassian/gostatsd)
5[![Build Status](https://travis-ci.org/atlassian/gostatsd.svg?branch=master)](https://travis-ci.org/atlassian/gostatsd)
6[![Coverage Status](https://coveralls.io/repos/github/atlassian/gostatsd/badge.svg?branch=master)](https://coveralls.io/github/atlassian/gostatsd?branch=master)
7[![GitHub tag](https://img.shields.io/github/tag/atlassian/gostatsd.svg?maxAge=86400)](https://github.com/atlassian/gostatsd)
8[![Docker Pulls](https://img.shields.io/docker/pulls/atlassianlabs/gostatsd.svg)](https://hub.docker.com/r/atlassianlabs/gostatsd/)
9[![Docker Stars](https://img.shields.io/docker/stars/atlassianlabs/gostatsd.svg)](https://hub.docker.com/r/atlassianlabs/gostatsd/)
10[![MicroBadger Layers Size](https://images.microbadger.com/badges/image/atlassianlabs/gostatsd.svg)](https://microbadger.com/images/atlassianlabs/gostatsd)
11[![Go Report Card](https://goreportcard.com/badge/github.com/atlassian/gostatsd)](https://goreportcard.com/report/github.com/atlassian/gostatsd)
12[![license](https://img.shields.io/github/license/atlassian/gostatsd.svg)](https://github.com/atlassian/gostatsd/blob/master/LICENSE)
13
14An implementation of [Etsy's][etsy] [statsd][statsd] in Go,
15based on original code from [@kisielk](https://github.com/kisielk/).
16
17The project provides both a server called "gostatsd" which works much like
18Etsy's version, but also provides a library for developing customized servers.
19
20Backends are pluggable and only need to support the [backend interface](backend.go).
21
22Being written in Go, it is able to use all cores which makes it easy to scale up the
23server based on load. The server can also be run HA and be scaled out, see
24[Load balancing and scaling out](https://github.com/atlassian/gostatsd#load-balancing-and-scaling-out).
25
26Building the server
27-------------------
28From the `gostatsd` directory run `make build`. The binary will be built in `build/bin/<arch>/gostatsd`.
29
30You will need to install the build dependencies by running `make setup` in the `gostatsd` directory. This must be done before the first build, and again if the dependencies change.
31
32If you are unable to build `gostatsd` please try running `make setup` again before reporting a bug.
33
34Running the server
35------------------
36`gostatsd --help` gives a complete description of available options and their
37defaults. You can use `make run` to run the server with just the `stdout` backend
38to display info on screen.
39You can also run through `docker` by running `make run-docker` which will use `docker-compose`
40to run `gostatsd` with a graphite backend and a grafana dashboard.
41
42Configuring backends and cloud providers
43----------------------------------------
44Backends and cloud providers are configured using `toml`, `json` or `yaml` configuration file
45passed via the `--config-path` flag. For all configuration options see source code of the backends you
46are interested in. Configuration file might look like this:
47```
48[graphite]
49	address = "192.168.99.100:2003"
50
51[datadog]
52	api_key = "my-secret-key" # Datadog API key required.
53
54[statsdaemon]
55	address = "docker.local:8125"
56	disable_tags = false
57
58[aws]
59	max_retries = 4
60```
61
62
63Configuring timer sub-metrics
64-----------------------------
65By default, timer metrics will result in aggregated metrics of the form (exact name varies by backend):
66```
67<base>.Count
68<base>.CountPerSecond
69<base>.Mean
70<base>.Median
71<base>.Lower
72<base>.Upper
73<base>.StdDev
74<base>.Sum
75<base>.SumSquares
76```
77
78
79In addition, the following aggregated metrics will be emitted for each configured percentile:
80```
81<base>.Count_XX
82<base>.Mean_XX
83<base>.Sum_XX
84<base>.SumSquares_XX
85<base>.Upper_XX - for positive only
86<base>.Lower_-XX - for negative only
87```
88
89
90These can be controlled through the `disabled-sub-metrics` configuration section:
91```
92[disabled-sub-metrics]
93# Regular metrics
94count=false
95count-per-second=false
96mean=false
97median=false
98lower=false
99upper=false
100stddev=false
101sum=false
102sum-squares=false
103
104# Percentile metrics
105count-pct=false
106mean-pct=false
107sum-pct=false
108sum-squares-pct=false
109lower-pct=false
110upper-pct=false
111```
112
113
114By default (for compatibility), they are all false and the metrics will be emitted.
115
116
117
118Sending metrics
119---------------
120The server listens for UDP packets on the address given by the `--metrics-addr` flag,
121aggregates them, then sends them to the backend servers given by the `--backends`
122flag (comma separated list of backend names).
123
124Currently supported backends are:
125
126* graphite
127* datadog
128* statsd
129* stdout
130
131The format of each metric is:
132
133    <bucket name>:<value>|<type>\n
134
135* `<bucket name>` is a string like `abc.def.g`, just like a graphite bucket name
136* `<value>` is a string representation of a floating point number
137* `<type>` is one of `c`, `g`, or `ms` for "counter", "gauge", and "timer"
138respectively.
139
140A single packet can contain multiple metrics, each ending with a newline.
141
142Optionally, `gostatsd` supports sample rates and tags (unused):
143
144* `<bucket name>:<value>|c|@<sample rate>\n` where `sample rate` is a float between 0 and 1
145* `<bucket name>:<value>|c|@<sample rate>|#<tags>\n` where `tags` is a comma separated list of tags
146* or `<bucket name>:<value>|<type>|#<tags>\n` where `tags` is a comma separated list of tags
147
148Tags format is: `simple` or `key:value`.
149
150
151A simple way to test your installation or send metrics from a script is to use
152`echo` and the [netcat][netcat] utility `nc`:
153
154    echo 'abc.def.g:10|c' | nc -w1 -u localhost 8125
155
156Monitoring
157----------
158Many metrics for the internal processes are emitted.  See METRICS.md for details.  Go expvar is also
159exposed if the `--profile` flag is used.
160
161Memory allocation for read buffers
162----------------------------------
163By default `gostatsd` will batch read multiple packets to optimise read performance. The amount of memory allocated
164for these read buffers is determined by the config options:
165
166    max-readers * receive-batch-size * 64KB (max packet size)
167
168The metric `avg_packets_in_batch` can be used to track the average number of datagrams received per batch, and the
169`--receive-batch-size` flag used to tune it.  There may be some benefit to tuning the `--max-readers` flag as well.
170
171Using the library
172-----------------
173In your source code:
174
175    import "github.com/atlassian/gostatsd/pkg/statsd"
176
177Documentation can be found via `go doc github.com/atlassian/gostatsd/pkg/statsd` or at
178https://godoc.org/github.com/atlassian/gostatsd/pkg/statsd
179
180Contributors
181------------
182
183Pull requests, issues and comments welcome. For pull requests:
184
185* Add tests for new features and bug fixes
186* Follow the existing style
187* Separate unrelated changes into multiple pull requests
188
189See the existing issues for things to start contributing.
190
191For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.
192
193Atlassian requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership).
194
195Prior to accepting your contributions we ask that you please follow the appropriate link below to digitally sign the CLA. The Corporate CLA is for those who are contributing as a member of an organization and the individual CLA is for those contributing as an individual.
196
197* [CLA for corporate contributors](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=e1c17c66-ca4d-4aab-a953-2c231af4a20b)
198* [CLA for individuals](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=3f94fbdc-2fbe-46ac-b14c-5d152700ae5d)
199
200License
201-------
202
203Copyright (c) 2012 Kamil Kisiel.
204Copyright @ 2016-2017 Atlassian Pty Ltd and others.
205
206Licensed under the MIT license. See LICENSE file.
207
208[etsy]: https://www.etsy.com
209[statsd]: https://www.github.com/etsy/statsd
210[netcat]: http://netcat.sourceforge.net/
211