A while back Etsy opensourced a little node.js daemon called StatsD that makes it easy for you to ‘Measure All the Things.’
In my current environment setting up graphs for the folks on the business team and on the dev team is difficult and time consuming as it has to funnel through ops. We’re a bottleneck
I’m hoping to implement StatsD to make graphing a service that most anyone can directly interact with and remove me and my team as the bottleneck.
Below are my notes for setting it up.
Most of this is shamelessly ripped off from the following sources and modified/updated for this tutorial:
First off, lets install all the prerequisites (assuming you have EPEL installed):
yum install -y gcc zlib-devel curl curl-devel \
git openssl rpm-build gcc-c++ rpm-build \
python-sqlite2 python-zope-interface
Grab and install the Whisper and Carbon components of Graphite:
rpm -Uvh http://launchpadlibrarian.net/61905162/whisper-0.9.7-1.noarch.rpm
rpm -Uvh http://launchpadlibrarian.net/61905213/carbon-0.9.7-1.noarch.rpm
Place the Carbon configs:
cp /opt/graphite/conf/carbon.conf{.example,}
cp /opt/graphite/conf/storage-schemas.conf{.example,}
Get the Twisted python framework:
curl http://pypi.python.org/packages/source/T/Twisted/Twisted-11.0.0.tar.bz2 | tar jxv
cd Twisted-11.0.0 ; python setup.py install
Grab and install Graphite Web:
rpm -Uvh http://launchpadlibrarian.net/62379647/graphite-web-0.9.7c-1.noarch.rpm
Place the Graphite settings:
cp /opt/graphite/webapp/graphite/local_settings.py{.example,}
Setup the Graphite vhost at /etc/httpd/conf.d/graphite.conf:
<VirtualHost *:80>
ServerName graphite.example.com
ServerAlias graphite
DocumentRoot "/opt/graphite/webapp"
ErrorLog /opt/graphite/storage/log/webapp/error.log
CustomLog /opt/graphite/storage/log/webapp/access.log common
<Location "/">
SetHandler python-program
PythonPath "['/opt/graphite/webapp'] + ['/usr/local/lib/python2.6/dist-packages/'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE graphite.settings
PythonDebug Off
PythonAutoReload Off
</Location>
<Location "/content/">
SetHandler None
</Location>
<Location "/media/">
SetHandler None
</Location>
Alias /media/ "/usr/lib/python2.4/site-packages/django/contrib/admin/media/"
</VirtualHost>
Restart httpd:
/etc/init.d/httpd restart
Setup a Graphite user:
python /opt/graphite/webapp/graphite/manage.py syncdb
Get the Carbon Cache going:
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ \
/opt/graphite/bin/carbon-cache.py start
Set some perms for Graphite storage directory.:
chown -R apache:apache /opt/graphite/storage/
Grab the node.js source:
wget http://nodejs.org/dist/v0.5.10/node-v0.5.10.tar.gz \
-O /usr/src/redhat/SOURCES/node-v0.5.10.tar.gz
Create the node.js spec file at /usr/src/redhat/SPECS/nodejs.spec:
%define ver 0.5.10
%define rel 1
%define jobs 2
Name: nodejs
Version: %{ver}
Release: %{rel}
Summary: Node's goal is to provide an easy way to build scalable network programs.
Group: Applications/Internet
License: Copyright Joyent, Inc. and other Node contributors.
URL: http://nodejs.org
Source0: http://nodejs.org/dist/node-v%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: python >= 2.4
%description
Node.js is a server-side JavaScript environment that uses an asynchronous
event-driven model. This allows Node.js to get excellent performance based on
the architectures of many Internet applications.
%prep
%setup -q -n node-v%{version}
%build
export JOBS=%{jobs}
./configure --prefix=/usr
make
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog LICENSE README.md
/usr/bin/node
/usr/bin/node-waf
/usr/include/node
/usr/lib/node
/usr/share/man/man1/node.1.gz
%changelog
* Sat Oct 29 2011 Nathan Milford <nathan@milford.io> 0.5.10-1
- New rpm using upstream 0.5.10, shamless ripoff, slight mods to inc the version.
* Thu Apr 14 2011 Chris Abernethy <cabernet@chrisabernethy.com> 0.4.6-1
- Initial rpm using upstream v0.4.6
Build and install the node.js RPM:
rpmbuild -ba /usr/src/redhat/SPECS/nodejs.spec
rpm -Uvh /usr/src/redhat/RPMS/x86_64/nodejs-0.5.10-1.x86_64.rpm
Install and setup the Node Package Manager (NPN):
curl http://npmjs.org/install.sh | sh
npm install express
Grab the stasd source and spec, build and install the RPM:
git clone git://github.com/oli99sc/statsd-rpm.git
mv statsd-rpm/is24-statsd-0.8.tar.gz /usr/src/redhat/SOURCES/
mv statsd-rpm/is24-statsd.spec /usr/src/redhat/SPECS/
rpmbuild -ba /usr/src/redhat/SPECS/is24-statsd.spec
rpm -Uvh /usr/src/redhat/RPMS/noarch/is24-statsd-0.8-1.noarch.rpm
Start stasd:
/etc/init.d/is24-statsd start
This is the best part and why I can’t wait to implement it, insert your first stat:
echo "testCounter:25|c" | nc -w 1 -u localhost 8125
One line and Boom.. Glorious Victory! New Stat!
Open up Graphite @ http://graphite/, login and view it.

Next step is to setup Tattle. I am super excited for Tattle, a self service alerting and dashboard frontend for graphite. Checkout the source here.
Got a lot more work to do to make it pretty so I can introduce it into my environment and give our developers a self-serve interface to graphing and alerting.
