Skip to content

Instantly share code, notes, and snippets.

@codeodor
Created February 11, 2013 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeodor/4758690 to your computer and use it in GitHub Desktop.
Save codeodor/4758690 to your computer and use it in GitHub Desktop.
Setting up statsd to run with the graphite backend.
git clone git://github.com/etsy/statsd.git
cd statsd
# yak shaving:
# install nodejs if you don't have it
brew install node # assuming you have/use homebrew
# install python if you don't have it
# I already had python due to it being packaged with MacOS, but if you don't have it, you'll need it
# pip : python :: gem : ruby
sudo easy_install pip # if you don't already have pip
# virtualenv : python :: rvm : ruby
sudo pip install virtualenv # if you don't already have virtualenv
virtualenv graphite # create virtual environment (will add graphite directory to keep isolation, I put it under statsd, but you could put wherever)
source graphite/bin/activate # changes $PATH to put graphite/bin first so all calls to python stuff will use the virtual environment you set up; `deactivate` will undo
# note: I use $PWD here because I put my virtualenv of "graphite" in the directory I was currently in. You will want to change it to make sure you are putting it in the virtualenv YOU used
pip install whisper --install-option="--prefix=$PWD/graphite" --install-option="--install-lib=$PWD/graphite/lib"
pip install carbon --install-option="--prefix=$PWD/graphite" --install-option="--install-lib=$PWD/graphite/lib"
pip install graphite-web --install-option="--prefix=$PWD/graphite" --install-option="--install-lib=$PWD/graphite/webapp"
pushd graphite #again, this is where I installed it
git clone git://anongit.freedesktop.org/py2cairo
cd py2cairo
./waf configure --prefix=$VIRTUAL_ENV
./waf build
./waf install
cd ..
pip install django tagging django-tagging Twisted gunicorn whisper # for production you'll probably also want to add: mod_python and memcache
curl https://launchpadlibrarian.net/104073214/check-dependencies.py > check-dependencies.py
python check-dependencies.py # to see any other dependencies you'll need to install
cd conf
cp carbon.conf.example carbon.conf
cp storage-schemas.conf.example storage-schemas.conf
cd ..
cp webapp/graphite/local_settings.py.example webapp/graphite/local_settings.py
# now open the local_settings.py and uncomment DATABASES= info, ensuring you change the name to point at where you installed graphite
python webapp/graphite/manage.py syncdb # like rake db:create && rake db:migrate
# see http://stackoverflow.com/a/7107521/28451 and modify the storage-schemas.conf file
./bin/carbon-cache.py start # start carbon
python webapp/graphite/manage.py runserver #start the django web app
cd ..
node stats.js exampleConfig.js # start statsd! ... make sure to set the values for the
# set up harness in your app (tell it to use real queue and whatnot if you have the queue and set StatsD.mode = :production if you are not really in production and want to have a look )
@codeodor
Copy link
Author

Also, don't forget to block the public ports on the firewall for statsd and graphite -- you don't want anyone to be able to mess with your stats!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment