How to Set Up Metric Collection Using Graphite and Statsd on Ubuntu 12.04 LTS
A few weeks ago, I talked about how Kinvey’s analytics help developers gain insight into their app’s usage. This insight is important, because it is a key factor in improving any product or service offering. Here, at Kinvey, we are committed to tracking every aspect of our service’s behavior in order to serve our customers better.
Visualizing your metrics is just as important as collecting them. We decided to use the awesome open source tool, graphite to help us visualize our application and system metrics. We also decided to leverage the fantastic work done by Etsy and use statsd, their simple node.js daemon that collects and aggregates metrics via UDP and flushes them to graphite.
You can find more information about graphite’s architecture here.
The flexibility offered by open source tools is often counterbalanced by the difficulty involved in setting them up. I thought it might be useful to document and share my learnings around installing and configuring graphite and statsd on Ubuntu 12.04 LTS and hope that it may benefit others.
- The install process assumes that you are running statsd and carbon/graphite-web on the same server
- The installation configuration for graphite currently has hardcoded paths to /opt/graphite. It is possible to change this but would require modification to the graphite installation scripts.
The following gist has all the steps to install and configure graphite and statsd.
To test your installation, do the following:
cd /opt/graphite && sudo ./bin/carbon-cache.py –debug start
cd /opt/graphite && sudo ./bin/run-graphite-devel-server.py .
cd /opt/statsd && node ./stats.js ./localConfig.js
Run the example client (any one will suffice, python client shown here):
cd /opt/statsd/examples && python ./python_example.py
Point your web browser at http://127.0.0.1:8080/ to bring up the graphite webapp and start creating graphs!
In a subsequent blog post, I will show you how to use nginx and gunicorn to serve up your graphite webapp.
Starting a new mobile project? Check out our mBaaS Savings Calculator for a price quote.