Logging Metrics in Gunicorn
-
Gunicorn provides an optional instrumentation of:
- The arbiter
- The workers
- This is provided using the
statsDprotocol over UDP - Specifically, Gunicorn uses the
gunicorn.instrument.statsdmodule - As a result, Gunicorn becomes a
statsDclient -
Using UDP ensures the following:
- Gunicorn is isolated from the receiving end of
statsD - Gunicorn is not held up by a slow
statsDconsumer
- Gunicorn is isolated from the receiving end of
Usage of statsD in Gunicorn
- An example of the
statsDserver is the following:
$ gunicorn --statsd-host=localhost:8125 ...Details about the statsD Logger
- The
statsDlogger overridesgunicorn.glogging.Logger - This tracks all of the requests
-
The following metrics are generated:
gunicorn.requests: Request rate per secondsgunicorn.request.duration: Histogram of request duration (in milliseconds)gunicorn.workers: Number of workers managed by the arbiter (gauge)gunicorn.log.critical: Rate of critical log messagesgunicorn.log.error: Rate of error log messagesgunicorn.log.warning: Rate of warning log messagesgunicorn.log.exception: Rate of exceptional log messages
References
Previous
Next