Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bhang/2703599 to your computer and use it in GitHub Desktop.
Save bhang/2703599 to your computer and use it in GitHub Desktop.
Install Graphite and statsd on Ubuntu 12.04 LTS (Precise Pangolin)
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install git to get statsd
sudo apt-get install git
# System level dependencies for Graphite
sudo apt-get install memcached python-dev python-pip sqlite3 libcairo2 \
libcairo2-dev python-cairo pkg-config
# Get latest pip
sudo pip install --upgrade pip
# Install carbon and graphite deps
cat >> /tmp/graphite_reqs.txt << EOF
django==1.3
python-memcached
django-tagging
twisted
whisper==0.9.9
carbon==0.9.9
graphite-web==0.9.9
EOF
sudo pip install -r /tmp/graphite_reqs.txt
#
# Configure carbon
#
cd /opt/graphite/conf/
sudo cp carbon.conf.example carbon.conf
# Create storage schema and copy it over
# Using the sample as provided in the statsd README
# https://github.com/etsy/statsd#graphite-schema
cat >> /tmp/storage-schemas.conf << EOF
# Schema definitions for Whisper files. Entries are scanned in order,
# and first match wins. This file is scanned for changes every 60 seconds.
#
# [name]
# pattern = regex
# retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ...
[stats]
priority = 110
pattern = ^stats\..*
retentions = 10s:6h,1m:7d,10m:1y
EOF
sudo cp /tmp/storage-schemas.conf storage-schemas.conf
# Make sure log dir exists for webapp
sudo mkdir -p /opt/graphite/storage/log/webapp
# Copy over the local settings file and initialize database
cd /opt/graphite/webapp/graphite/
sudo cp local_settings.py.example local_settings.py
sudo python manage.py syncdb # Follow the prompts, creating a superuser is optional
# statsd
cd /opt && sudo git clone git://github.com/etsy/statsd.git
# StatsD configuration
cat >> /tmp/localConfig.js << EOF
{
graphitePort: 2003
, graphiteHost: "127.0.0.1"
, port: 8125
}
EOF
sudo cp /tmp/localConfig.js /opt/statsd/localConfig.js
@msiebuhr
Copy link

An possible improvement - add the --yes-flag to all apt-get-operations, so the user won't get prompted as much.

@bartek
Copy link

bartek commented Sep 25, 2012

Thank you for this, this was the key to getting statsd + graphite setup.

Copy link

ghost commented Jan 10, 2013

Thank you very much for this, made my day easier :)

@dochong
Copy link

dochong commented Jan 29, 2013

thank you very much.

@ndbroadbent
Copy link

Awesome, thank you! Worked perfectly!

@ronikb
Copy link

ronikb commented Feb 18, 2013

Installed it successfully. How to start statsd and graphite?

@compwright
Copy link

Just run:

sudo /opt/graphite/bin/carbon-cache.py

@urog
Copy link

urog commented Apr 29, 2013

You could also add a </dev/null at the end of the apt-add-repository command:

sudo apt-add-repository ppa:chris-lea/node.js </dev/null

@justincwatt
Copy link

Just a heads up: when running the script above from a stock install of Ubuntu 12.04, make sure to run sudo apt-get update before sudo apt-get install python-software-properties, otherwise the latter will fail.

Also, "As of Node.js v0.10.0, the nodejs package from Chris Lea's repo includes both npm and nodejs-dev," so no need to apt-get install npm.

@Gmagella
Copy link

Gmagella commented Jul 3, 2013

Hey! Thanks for the script... a newbie question: How can I put that in init? I want it to start with the system.
Thanks

@blackrosezy
Copy link

@Gmagella use Ubuntu upstart

@agentgt
Copy link

agentgt commented Dec 9, 2013

@czaban
Copy link

czaban commented Feb 23, 2014

ubuntu-12.04.4-server-amd64 - fresh installation:

Traceback (most recent call last):
File "manage.py", line 11, in
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 438, in execute_manager
[... a lot of...]

ImportError: cannot import name python_2_unicode_compatible

Any suggestions?

@gerard780
Copy link

@czaban change /tmp/graphite_reqs.txt to be django-tagging==0.3.1

@ionutzp
Copy link

ionutzp commented Apr 4, 2014

@czaban thanks! i had to reinstall with the django-tagging version but it worked

@fideloper
Copy link

So far, on Ubuntu 14.04:

  • Installed Django 1.5 (clears cannot import name python_2_unicode_compatible error)
  • sudo vim /opt/graphite/webapp/graphite/settings.py - set the SECRET_KEY to something.

Set a database in local_settings.py.

Error received during sudo python manage.py syncdb:

ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

Anyone know of an example of 14.04? I'm running out of time to track all the various dependencies :D

Edit: This might be the ticket - on 14.04, there appears to be an apt package.

@grekpg
Copy link

grekpg commented May 18, 2015

I try install on this vagrant - https://github.com/irmantas/symfony2-vagrant and have error

vagrant@precise64:/opt/graphite/webapp/graphite$ sudo python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 219, in execute
self.validate()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
import(name)
File "/opt/graphite/webapp/graphite/events/models.py", line 10, in
from tagging.fields import TagField
File "/usr/local/lib/python2.7/dist-packages/tagging/fields.py", line 9, in
from .models import Tag
File "/usr/local/lib/python2.7/dist-packages/tagging/models.py", line 6, in
from django.utils.encoding import smart_text
ImportError: cannot import name smart_text

@cybercupcake
Copy link

I got the exact same error as the commenter above. Anybody got a solution?

Trying to install on Ubuntu 14.04 X64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment