Python StatsD Client

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

python-statsd is a client for statsd, the metrics aggregation daemon that started at Etsy and now lives in its own organisation, sitting in front of Graphite. 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

  • Quickstart gets you from nothing to metrics on a graph, in two tracks: one minute without Docker, five minutes with.

  • 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