Etsy has followed the pattern of yahoo and flickr in developing a philosophy of measurement. Click here to see their post.
They created a node.js application called StatsD which makes capturing the measurements easier. It’s now open source.
Before you can use StatsD, you will want to install Graphite. StatsD can use multiple backends for graphing, it was originally designed for use with graphite.
Here are the steps to getting graphite installed on aws. I chose to use the Amazon linux ami.
- Open the graphite installation page.
- Login to the aws console.
- Create an ec2 instance (type Amazon linux which is based on centos).
- Be sure your security group allows http traffic through on port 80 and ssh so you can access it and UDP on port 8125.
- Login to the new instance (using ssh, keys and default username ec2-user)
- Create a new user to run the service (e.g., newuser)
- sodu -i (change to root for a while)
- yum update (updates all installed packages)
- sudo yum install git (will be needed to install graphite)
- Following instructions from graphite page:
- yum install python (ensure python is installed. You’ll need the version later.)
- Install pre-requisites
- yum install pycairo
- yum install mod_python
- easy_install pip (needed to install django)
- pip install django
- yum install -y gcc make (needed to install packages later)
- skipping ldap for now
- yum install python-memcached
- skip sql lite for now
- yum install mod_wsgi (referenced in the graphite http config file. be sure it’s installed).
- cd /opt
- mkdir graphite
- chown newuser:newuser graphite
- mkdir carbon
- chown newuser:newuser carbon
- mkdir whisper
- chown newuser:newuser whisper
- su newuser (change to the newser for now)
- cd /opt (if necessary)
- git clone https://github.com/graphite-project/graphite-web.git graphite
- git clone https://github.com/graphite-project/carbon.git carbon
- git clone https://github.com/graphite-project/whisper.git whisper
- Follow directions from graphite install page to change branch to 0.9.x for all three repos
- Follow direction to install whisper & carbon
- Follow directions to configure carbon except get info for configuration files from StatsD page.
- Follow directions on graphite install page to configure graphite webapp
- Configure apache. (The apache configuration file is located at /etc/httpd/conf/httpd.conf and explicitly include /etc/http/conf.d/*.conf). Copy the example config file to that location:
cp /opt/graphite/examples/example-graphite-vhost.conf graphite.conf /etc/httpd/conf.d/graphite.conf
- service httpd start (not started by default. Need to set it for auto start)
- /etc/init.d/httpd reload (not necessary but for clarity with the graphite install instructions and to make sure the config file works.)
- exit (return to working as the “newuser”)
- Initial Database Creation (from graphite install page)
- cd /opt/graphite/webapp/graphite
- You need to create a local_settings.py file.
cp local_settings.py.example local_settings.py
Edit lcoal_settings.py. Find the datbase section and uncomment:
DATABASES = {
‘default’: {
‘NAME’: ‘/opt/graphite/storage/graphite.db’,
‘ENGINE’: ‘django.db.backends.sqlite3’,
‘USER’: ”,
‘PASSWORD’: ”,
‘HOST’: ”,
‘PORT’: ”
}
}
- Create a root database user when prompted.
- changed owner of graphite.db to apache:apache
- Had an apache error in the logs about incorrect python version. Removed all referencces to mod_python as described in this post. Basically if you’re using mod_wsdi you shouldn’t be using mod_python.
- Restarted apache: sudo service https restart
- Received a 404 error at this point. Found the error in the graphite logs /opt/graphite/storage/logs/webapp/error.log
- cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
- Now I’m getting a 500 internal server error. Progress 😉
- There is an error in the graphite webapp error.log file:
Permission denied: ‘/opt/graphite/storage/log/webapp/info.log’
- chown apache:apache /opt/graphite/storage
- sudo service httpd restart
- chown apache:apache /opt/graphite/storage
- chown apache:apache /opt/graphite/storage/log/
- chown apache:apache /opt/graphite/storage/log/webapp/
- cd /opt/graphite/storage/log/webapp/
- chown apache:apache *
- service httpd restart
It works!