Last Updated: February 25, 2016
·
3.748K
· otupman

How to integrate statsd metrics into nginx (debian)

We're using the awesome combination of statsd and graphite to Measure All The Things (tm), so nginx was next on our list. There's a custom module available, but you have to build it in manually. There's a good blog post by Simon Potter, Building nginx for Debian systems, but it's a little out of date (by a step or two), so here's an updated version:

First off, we prep our build:

mkdir custom-nginx
cd custom-nginx
apt-get source nginx
cd nginx-1.2.1

Next up, we download the statsd module. At this point you could also download any other 3rd party modules as well.

cd debian/modules
wget https://github.com/zebrafishlabs/nginx-statsd/archive/master.zip
unzip master.zip
rm master.zip
cd ..
vim rules

Now we need to modify the rules and locate the build we wish to add the module to. By default you'll get: full, light, extras and naxi. You could also add your own custom build; totally your preference. Regardless of which direction you go, you need to add the following add-module line:

--add-module=$(MODULESDIR)/nginx-statsd-master \

For more options, the standard modules can be found at this link and here is nginx's list of known third party modules.

Next up, build dependencies and building the package itself:

apt-get build-dep nginx
dpkg-buildpackage

The build process will result in a series of packages; pick the one that suits - if you defined your fully custom configuration then that'll be the one you want. You'll find them in the parent directory in many different flavours!