statsd is a friendly front-end to Graphite. This is a Python client for the statsd daemon.
Code: | https://github.com/jsocol/pystatsd |
---|---|
License: | MIT; see LICENSE file |
Issues: | https://github.com/jsocol/pystatsd/issues |
Documentation: | https://statsd.readthedocs.io/ |
Quickly, to use:
>>> import statsd
>>> c = statsd.StatsClient('localhost', 8125)
>>> c.incr('foo') # Increment the 'foo' counter.
>>> c.timing('stats.timed', 320) # Record a 320ms 'stats.timed'.
You can also add a prefix to all your stats:
>>> import statsd
>>> c = statsd.StatsClient('localhost', 8125, prefix='foo')
>>> c.incr('bar') # Will be 'foo.bar' in statsd/graphite.
If your network is not stable, you can add retry (version>=4.0.2)
>>> import statsd
>>> c = statsd.StatsClient('localhost', 8125, prefix='foo', send_retries=2) # will try total 2 times (default is 1) when send data
>>> c.incr('bar')
The easiest way to install statsd is with pip!
You can install from PyPI:
$ pip install statsd
Or GitHub:
$ pip install -e git+https://github.com/jsocol/pystatsd#egg=statsd
Or from source:
$ git clone https://github.com/jsocol/pystatsd $ cd pystatsd $ python setup.py install
There are lots of docs in the docs/
directory and on ReadTheDocs.
Build package by poetry:
pip install poetry poetry config repositories.<repo-name> <repo-url> poetry config http-basic.<repo-name> <user-name> <password> poetry build poetry publish -r <repo-name> # or with user and password poetry publish -r <repo-name> -u <user-name> -p <password>