Using Etsy's StatsD in a Windows Environment

Christopher picture Christopher · Mar 25, 2011 · Viewed 11k times · Source

What will I need to use Etsy's Statsd in a Windows Environment? My intentions are to create a .net client to use Statsd.

Answer

fiat picture fiat · Jun 5, 2012

I have statsd+graphite running in my Windows environment using the C# client NStatsD.

Here are my notes for getting the Linux VM setup:

Note: I know enough Linux to be dangerous but am otherwise a noob and could be doing something unwittingly horrible.

  1. Install Ubuntu Server 12.04. I used VirtualBox for dev and then later EC2 for prod.
  2. Download graphite-fabric to your home folder. This is a script that will download, compile and install graphite and statsd. It expects a clean box and uses nginx for the web server.

    sudo apt-get install git

    git clone git://github.com/gingerlime/graphite-fabric.git

    cd graphite-fabric/

  3. Install prereq's for fabric

    sudo apt-get install python-setuptools

  4. The next steps are a download, compile and install which can take some time. It is worthwhile setting a keep alive on any putty ssh session before continuing.

  5. Now install as per gingerlime's instructions in the README.md - including the requirements section.

  6. Install statsd as per gingerlime's instructions.
  7. Reboot
  8. Execute netstat -nulp and observe 8125 is in use to confirm statsd is listening.
  9. Check carbon is running tail /opt/graphite/storage/log/carbon-cache/carbon-cache-a/listener.log. If it isn't, try sudo /etc/init.d/carbon start

Now you have your server running, try throwing some counters at it with the NStatsD client.

Timezone fix:

This will fix graphite to graph times in your local zone

  1. cd /opt/graphite/webapp/graphite
  2. sudo cp local_settings.py.example local_settings.py
  3. sudo chown www-data:www-data local_settings.py (check with ls -l that permissions look right)
  4. sudo pico local_settings.py Set TIME_ZONE to something like Australia/Sydney. Discover what timezones you can use in /usr/share/zoneinfo/
  5. Save and restart the box (not sure how to make it pick up the change without restart)

EC2 Notes

root is disabled on EC2. Fabric prompts for a root password which you don't have. Use the -i keyfile argument with fab to give it your ssh keyfile instead.

VirtualBox Notes

VBoxVMService was handy to automatically run the VM as a service in my Windows dev environment.