Document statsd_* commands.

This commit is contained in:
Berker Peksag 2014-12-01 07:04:10 +02:00
parent 43d1eba3e3
commit f0b9468ea3
5 changed files with 52 additions and 33 deletions

View File

@ -45,35 +45,6 @@ Example with test app::
$ gunicorn --workers=2 test:app
Instrumentation
---------------
Gunicorn provides an optional instrumentation of the arbiter and
workers using the statsD_ protocol over UDP. Thanks to the
`gunicorn.instrument.statsd` module, Gunicorn becomes a statsD client
The use of UDP cleanly isolates Gunicorn from the receiving end of the statsD
metrics so that instrumentation does not cause Gunicorn to be held up by a slow
statsD consumer.
To use statsD, just tell gunicorn where the statsD server is:
$ gunicorn --statsd-host=localhost:8125 ...
The `Statsd` logger overrides `gunicorn.glogging.Logger` to track
all requests. The following metrics are generated:
* ``gunicorn.requests``: request rate per second
* ``gunicorn.request.duration``: histogram of request duration (in millisecond)
* ``gunicorn.workers``: number of workers managed by the arbiter (gauge)
* ``gunicorn.log.critical``: rate of critical log messages
* ``gunicorn.log.error``: rate of error log messages
* ``gunicorn.log.warning``: rate of warning log messages
* ``gunicorn.log.exception``: rate of exceptional log messages
To generate new metrics you can `log.info` with a few additional keywords::
log.info("...", extra={"metric": "my.metric", "value": "1.2", "mtype": "gauge"})
License
-------

View File

@ -40,6 +40,7 @@ Contents
run
configure
settings
instrumentation
deploy
design
signals

View File

@ -0,0 +1,37 @@
.. _instrumentation:
===============
Instrumentation
===============
.. versionadded:: 19.1
Gunicorn provides an optional instrumentation of the arbiter and
workers using the statsD_ protocol over UDP. Thanks to the
``gunicorn.instrument.statsd`` module, Gunicorn becomes a statsD client
The use of UDP cleanly isolates Gunicorn from the receiving end of the statsD
metrics so that instrumentation does not cause Gunicorn to be held up by a slow
statsD consumer.
To use statsD, just tell gunicorn where the statsD server is:
.. code-block:: bash
$ gunicorn --statsd-host=localhost:8125 ...
The ``Statsd`` logger overrides ``gunicorn.glogging.Logger`` to track
all requests. The following metrics are generated:
* ``gunicorn.requests``: request rate per second
* ``gunicorn.request.duration``: histogram of request duration (in millisecond)
* ``gunicorn.workers``: number of workers managed by the arbiter (gauge)
* ``gunicorn.log.critical``: rate of critical log messages
* ``gunicorn.log.error``: rate of error log messages
* ``gunicorn.log.warning``: rate of warning log messages
* ``gunicorn.log.exception``: rate of exceptional log messages
To generate new metrics you can ``log.info`` with a few additional keywords::
log.info("...", extra={"metric": "my.metric", "value": "1.2", "mtype": "gauge"})
.. _statsD: http://github.com/etsy/statsd

View File

@ -956,7 +956,9 @@ statsd_host
* ``--statsd-host STATSD_ADDR``
* ``None``
host:port of the statsd server to log to
``host:port`` of the statsd server to log to.
.. versionadded:: 19.1
statsd_prefix
~~~~~~~~~~~~~
@ -964,5 +966,8 @@ statsd_prefix
* ``--statsd-prefix STATSD_PREFIX``
* ````
Prefix to use when emitting statsd metrics (a trailing . is added, if not provided)
Prefix to use when emitting statsd metrics (a trailing ``.`` is added,
if not provided).
.. versionadded:: 19.2

View File

@ -1669,7 +1669,9 @@ class StatsdHost(Setting):
default = None
validator = validate_hostport
desc = """\
host:port of the statsd server to log to
``host:port`` of the statsd server to log to.
.. versionadded:: 19.1
"""
class StatsdPrefix(Setting):
@ -1680,5 +1682,8 @@ class StatsdPrefix(Setting):
default = ""
validator = validate_string
desc = """\
Prefix to use when emitting statsd metrics (a trailing . is added, if not provided)
Prefix to use when emitting statsd metrics (a trailing ``.`` is added,
if not provided).
.. versionadded:: 19.2
"""