Coder Social home page Coder Social logo

gstatsd's Introduction

gstatsd - A statsd service implementation in Python + gevent.

If you are unfamiliar with statsd, you can read why statsd exists, or look at the NodeJS statsd implementation.

License: Apache 2.0

Requirements

  • Python - I'm testing on 2.6/2.7 at the moment.
  • gevent - A libevent wrapper.
  • distribute - (or setuptools) for builds.

Using gstatsd

Show gstatsd help:

% gstatsd -h

Options:

Usage: gstatsd [options]

 A statsd service in Python + gevent.

Options:
  --version             show program's version number and exit
  -b BIND_ADDR, --bind=BIND_ADDR
                        bind [host]:port (host defaults to '')
  -s SINK, --sink=SINK  a graphite service to which stats are sent
                        ([host]:port).
  -v                    increase verbosity (currently used for debugging)
  -f INTERVAL, --flush=INTERVAL
                        flush interval, in seconds (default 10)
  -p PERCENT, --percent=PERCENT
                        percent threshold (default 90)
  -D, --daemonize       daemonize the service
  -h, --help

Start gstatsd listening on the default port 8125, and send stats to graphite server on port 2003 every 5 seconds:

% gstatsd -s 2003 -f 5

Bind listener to host 'foo' port 8126, and send stats to the Graphite server on host 'bar' port 2003 every 20 seconds:

% gstatsd -b foo:8126 -s bar:2003 -f 20

To send the stats to multiple graphite servers, specify '-s' multiple times:

% gstatsd -b :8125 -s stats1:2003 -s stats2:2004

Using the client

The code example below demonstrates using the low-level client interface:

from gstatsd import client

# location of the statsd server
hostport = ('', 8125)

raw = client.StatsClient(hostport)

# add 1 to the 'foo' bucket
raw.increment('foo')

# timer 'bar' took 25ms to complete
raw.timer('bar', 25)

You may prefer to use the stateful client:

# wraps the raw client
cli = client.Stats(raw)

timer = cli.get_timer('foo')
timer.start()

... do some work ..

# when .stop() is called, the stat is sent to the server
timer.stop()

gstatsd's People

Contributors

phensley avatar aadis avatar

Watchers

Mathieu Lecarme avatar Gael Pasgrimaud avatar Johan Charpentier avatar guyzmo avatar James Cloos avatar  avatar Vincent Caron avatar  avatar _nirae avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.