同步操作将从 Gitee 极速下载/StatsD 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
A network daemon that runs on the [Node.js][node] platform and listens for statistics, like counters and timers, sent over [UDP][udp] and sends aggregates to one or more pluggable backend services (e.g., [Graphite][graphite]).
We ([Etsy][etsy]) [blogged][blog post] about how it works and why we created it.
buckets Each stat is in its own "bucket". They are not predefined anywhere. Buckets can be named anything that will translate to Graphite (periods make folders, etc)
values Each stat will have a value. How it is interpreted depends on modifiers. In general values should be integer.
flush After the flush interval timeout (default 10 seconds), stats are aggregated and sent to an upstream backend service.
gorets:1|c
This is a simple counter. Add 1 to the "gorets" bucket. It stays in memory until the flush interval config.flushInterval
.
glork:320|ms
The glork took 320ms to complete this time. StatsD figures out 90th percentile,
average (mean), 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
Where $KEY
is the key you stats key you specify when sending to statsd, and
$PCT
is the percentile threshold.
gorets:1|c|@0.1
Tells StatsD that this counter is being sent sampled every 1/10th of the time.
StatsD now also supports gauges, arbitrary values, which can be recorded.
gaugor:333|g
All metrics can also be batch send in a single UDP packet, separated by a newline character.
There are additional config variables available for debugging:
debug
- log exceptions and periodically print out information on counters and timersdebugInterval
- interval for printing out information on counters and timersdumpMessages
- print debug info on incoming messagesFor more information, check the exampleConfig.js
.
StatsD supports multiple, pluggable, backend modules that can publish statistics from the local StatsD daemon to a backend service or data store. Backend services can retain statistics for longer durations in a time series data store, visualize statistics in graphs or tables, or generate alerts based on defined thresholds. A backend can also correlate statistics sent from StatsD daemons running across multiple hosts in an infrastructure.
StatsD includes the following backends:
graphite
): Graphite is an open-source
time-series data store that provides visualization through a
web-browser interface.console
): The console backend outputs the received
metrics to stdout (e.g. for seeing what's going on during development).By default, the graphite
backend will be loaded automatically. To
select which backends are loaded, set the backends
configuration
variable to the list of backend modules to load.
Backends are just npm modules which implement the interface described in
section Backend Interface. In order to be able to load the backend, add the
module name into the backends
variable in your config. As the name is also
used in the require
directive, you can load one of the provided backends by
giving the relative path (e.g. ./backends/graphite
).
Graphite uses "schemas" to define the different round robin datasets it houses (analogous to RRAs in rrdtool). Here's an example for the stats databases:
In conf/storage-schemas.conf:
[stats]
pattern = ^stats\..*
retentions = 10:2160,60:10080,600:262974
In conf/storage-aggregation.conf:
[min]
pattern = \.min$
xFilesFactor = 0.1
aggregationMethod = min
[max]
pattern = \.max$
xFilesFactor = 0.1
aggregationMethod = max
[sum]
pattern = \.count$
xFilesFactor = 0
aggregationMethod = sum
[default_average]
pattern = .*
xFilesFactor = 0.3
aggregationMethod = average
This translates to:
(Note: Newer versions of Graphite can take human readable time formats like 10s:6h,1min:7d,10min:5y)
Retentions and aggregations are read from the file in order, the first pattern that matches is used. This is set when the database is first created, changing these config files will not change databases that have already been created. To view or alter the settings on existing files, use whisper-info.py and whisper-resize.py included with the Whisper package.
These settings have been a good tradeoff so far between size-of-file (round robin databases are fixed size) and data we care about. Each "stats" database is about 3.2 megs with these retentions.
Many users have been confused to see their hit counts averaged, missing when the data is intermittent, or never stored when statsd is sending at a different interval than graphite expects. Storage aggregation settings will help you control this and understand what Graphite is doing internally with your data.
A really simple TCP management interface is available by default on port 8126 or overriden in the configuration file. Inspired by the memcache stats approach this can be used to monitor a live statsd server. You can interact with the management server by telnetting to port 8126, the following commands are available:
The stats output currently will give you:
Each backend will also publish a set of statistics, prefixed by its module name.
Graphite:
A simple nagios check can be found in the utils/ directory that can be used to check metric thresholds, for example the number of seconds since the last successful flush to graphite.
Install node.js
Clone the project
Create a config file from exampleConfig.js and put it somewhere
Start the Daemon:
node stats.js /path/to/config
A test framework has been added using node-unit and some custom code to start and manipulate statsd. Please add tests under test/ for any new features or bug fixes encountered. Testing a live server can be tricky, attempts were made to eliminate race conditions but it may be possible to encounter a stuck state. If doing dev work, a killall node
will kill any stray test servers in the background (don't do this on a production machine!).
Tests can be executd with ./run_tests.sh
.
Backend modules are Node.js [modules][nodemods] that listen for a number of events emitted from StatsD. Each backend module should export the following initialization function:
init(startup_time, config, events)
: This method is invoked from StatsD to
initialize the backend module. It accepts three parameters:
startup_time
is the startup time of StatsD in epoch seconds,
config
is the parsed config file hash, and events
is the event
emitter that backends can use to listen for events.
The backend module should return true
from init() to indicate
success. A return of false
indicates a failure to load the module
(missing configuration?) and will cause StatsD to exit.
Backends can listen for the following events emitted by StatsD from
the events
object:
Event: 'flush'
Parameters: (time_stamp, metrics)
Emitted on each flush interval so that backends can push aggregate
metrics to their respective backend services. The event is passed
two parameters: time_stamp
is the current time in epoch seconds
and metrics
is a hash representing the StatsD statistics:
metrics: { counters: counters, gauges: gauges, timers: timers, pctThreshold: pctThreshold }
Each backend module is passed the same set of statistics, so a
backend module should treat the metrics as immutable
structures. StatsD will reset timers and counters after each
listener has handled the event.
* Event: **'status'**
Parameters: `(writeCb)`
Emitted when a user invokes a *stats* command on the management
server port. It allows each backend module to dump backend-specific
status statistics to the management port.
The `writeCb` callback function has a signature of `f(error,
backend_name, stat_name, stat_value)`. The backend module should
invoke this method with each stat_name and stat_value that should be
sent to the management port. StatsD will prefix each stat name with
the `backend_name`. The backend should set `error` to *null*, or, in
the case of a failure, an appropriate error.
Inspiration
-----------
StatsD was inspired (heavily) by the project (of the same name) at Flickr. Here's a post where Cal Henderson described it in depth:
[Counting and timing](http://code.flickr.com/blog/2008/10/27/counting-timing/). Cal re-released the code recently: [Perl StatsD](https://github.com/iamcal/Flickr-StatsD)
Meta
---------
- IRC channel: `#statsd` on freenode
- Mailing list: `statsd@librelist.com`
Contribute
---------------------
You're interested in contributing to StatsD? *AWESOME*. Here are the basic steps:
fork StatsD from here: http://github.com/etsy/statsd
1. Clone your fork
2. Hack away
3. If you are adding new functionality, document it in the README
4. If necessary, rebase your commits into logical chunks, without errors
5. Push the branch up to GitHub
6. Send a pull request to the etsy/statsd project.
We'll do our best to get your changes in!
[graphite]: http://graphite.wikidot.com
[etsy]: http://www.etsy.com
[blog post]: http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/
[node]: http://nodejs.org
[nodemods]: http://nodejs.org/api/modules.html
[udp]: http://en.wikipedia.org/wiki/User_Datagram_Protocol
Contributors
-----------------
In lieu of a list of contributors, check out the commit history for the project:
https://github.com/etsy/statsd/graphs/contributors
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。