Python StatsD Client

Metrics leave your application over UDP, statsd aggregates them, Graphite stores and graphs them

python-statsd is a client for Etsy’s statsd server, a front end and proxy for the Graphite stats collection and graphing server. It supports Python 3.10 and newer, and it has no dependencies.

Install it, point it at a server, and send something:

pip install python-statsd
import statsd

counter = statsd.Counter('app')
counter += 1

with statsd.Timer('app').time('render'):
    render_page()

Those two metrics arrive as app:1|c and app.render:12.4|ms, one UDP packet each. Nothing blocks, nothing is retried, and a statsd server that is down costs you graphs rather than requests.

Where to go next

  • Metrics covers the five metric types, how to choose between them, and the exact bytes each one writes.

  • Connections covers destinations, sampling, disabling and what happens when a send fails.

  • Patterns covers naming, client trees, web framework integration and the decisions that age badly.

  • A local stack brings up statsd, Graphite and Grafana with one command so you can watch a metric land.

Indices and Tables