Skip to content

Instantly share code, notes, and snippets.

@trusche
Last active May 2, 2019 13:05
Show Gist options
  • Select an option

  • Save trusche/bfab931c538bd1a63c80 to your computer and use it in GitHub Desktop.

Select an option

Save trusche/bfab931c538bd1a63c80 to your computer and use it in GitHub Desktop.
Installing graphite and statsd on OS X Yosemite

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Graphite

Install Cairo

There's an issue with cairo 14.x that results in the axis fonts on the graphs being HUUUUUGE. Downgrading to 12.6 helps:

cd /usr/local/Library/
git checkout 7073788 /usr/local/Library/Formula/cairo.rb
brew install cairo
brew install py2cairo
sudo pip install cairocffi

Install Django

pip install Django==1.8
pip install django-tagging

Install Graphite

sudo pip install carbon
pip install whisper
sudo pip install graphite-web
sudo pip install Twisted==15.2

sudo chown -R <your username>:staff /opt/graphite

Configure graphite

cd /opt/graphite
cp conf/carbon.conf{.example,}
cp conf/storage-schemas.conf{.example,}

cd webapp/graphite

# Modify this file to change database backend (default is sqlite).
cp local_settings.py{.example,}

# Initialize database
python manage.py syncdb

Start carbon & graphite

python /opt/graphite/bin/carbon-cache.py start

(Ignore this error: WHISPER_FALLOCATE_CREATE is enabled but linking failed.)

python /opt/graphite/bin/run-graphite-devel-server.py /opt/graphite

Hope that it works!

Go to:

http://localhost:8080

You should see this if it works properly:

bacon

If you get a broken image, it most likely means that something is wrong py2cairo and cairo.

Check the debug output here:

http://localhost:8080/render

Optional convenience aliases

Add this to your .bashrc or .bash_profile or .aliasrc:

alias carbon='python /opt/graphite/bin/carbon-cache.py'
alias graphite-web='python /opt/graphite/bin/run-graphite-devel-server.py /opt/graphite'

Statsd

Install Node

brew install nodejs

Clone the repo

sudo git clone https://github.com/etsy/statsd.git /opt/statsd
sudo chown -R trusche:staff /opt/statsd

Configure statsd

cp /opt/statsd/exampleConfig.js /opt/statsd/config.js

Fire it up!

node /opt/statsd/stats.js /opt/statsd/config.js

node statsd /

Resources

@alexeystrakh
Copy link
Copy Markdown

Thank you for the guide, unfortunately I'm unable to pass the Configuration step. I'm using the default installation environment. The following step gives me an error:

$ python manage.py syncdb

Could not import graphite.local_settings, using defaults!
Traceback (most recent call last):
File "manage.py", line 13, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/init.py", line 316, in execute
settings.INSTALLED_APPS
File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 53, in getattr
self._setup(name)
File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/site-packages/django/conf/init.py", line 97, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/opt/graphite/webapp/graphite/settings.py", line 151, in
from graphite.app_settings import * # noqa
ImportError: No module named graphite.app_settings

If I start the graphite after that I get the following warning which is basically says that I have to complete my previous step (but how?):

You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions, tagging.
Run 'python manage.py migrate' to apply them.

And then I can start the graphite & carbon and my localhost:8080 gives me an error:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/graphite/webapp/graphite/composer/views.py", line 35, in composer
profile = getProfile(request)
File "/opt/graphite/webapp/graphite/util.py", line 66, in getProfile
return default_profile()
File "/opt/graphite/webapp/graphite/util.py", line 132, in default_profile
'password': '!'})
File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 473, in get_or_create
return self.get(**lookup), False
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 379, in get
num = len(clone)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 238, in len
self._fetch_all()
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 54, in iter
results = compiler.execute_sql()
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
OperationalError: no such table: auth_user

I guess I'm missing some important configuration with database which is not outlined in this guide, could you please advise?

@piotr1212
Copy link
Copy Markdown

For the record:

$ python manage.py syncdb

changed into:
django-admin.py migrate --settings=graphite.settings --run-syncdb

See https://graphite.readthedocs.io/en/latest/config-database-setup.html for more information.

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