Skip to content

Instantly share code, notes, and snippets.

@andrewmichaelsmith
Last active October 27, 2015 15:54
Show Gist options
  • Save andrewmichaelsmith/9565983 to your computer and use it in GitHub Desktop.
Save andrewmichaelsmith/9565983 to your computer and use it in GitHub Desktop.
graphite setup
# This needs to be in your server's config somewhere, probably
# the main httpd.conf
# NameVirtualHost *:80
# This line also needs to be in your server's config.
# LoadModule wsgi_module modules/mod_wsgi.so
# You need to manually edit this file to fit your needs.
# This configuration assumes the default installation prefix
# of /opt/graphite/, if you installed graphite somewhere else
# you will need to change all the occurances of /opt/graphite/
# in this file to your chosen install location.
<IfModule !wsgi_module.c>
LoadModule wsgi_module modules/mod_wsgi.so
</IfModule>
# XXX You need to set this up!
# Read http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGISocketPrefix
WSGISocketPrefix run/wsgi
<VirtualHost *:80>
ServerName graphite
DocumentRoot "/opt/graphite/webapp"
ErrorLog /opt/graphite/storage/log/webapp/error.log
CustomLog /opt/graphite/storage/log/webapp/access.log common
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, OPTIONS"
Header set Access-Control-Allow-Headers "origin, authorization,
# I've found that an equal number of processes & threads tends
# to show the best performance for Graphite (ymmv).
WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
# XXX You will need to create this file! There is a graphite.wsgi.example
# file in this directory that you can safely use, just copy it to graphite.wgsi
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
Alias /content/ /opt/graphite/webapp/content/
<Location "/content/">
SetHandler None
Order deny,allow
Allow from all
Require all granted
</Location>
# XXX In order for the django admin site media to work you
# must change @DJANGO_ROOT@ to be the path to your django
# installation, which is probably something like:
# /usr/lib/python2.6/site-packages/django
Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"
<Location "/media/">
SetHandler None
</Location>
# The graphite.wsgi file has to be accessible by apache. It won't
# be visible to clients because of the DocumentRoot though.
<Directory /opt/graphite/conf/>
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost grafana:80>
ServerName grafana
DocumentRoot "/opt/grafana/"
</VirtualHost>
<Directory "/opt/grafana">
Require all granted
</Directory>
sudo su
apt-get install -y apache2 libapache2-mod-wsgi python-pip gcc python2.7-dev python-cairo
a2enmod headers
pip install django=="1.5"
pip install 'Twisted<12.0' #carbon and newer twisted versions don't play well
pip install https://github.com/graphite-project/ceres/tarball/master
pip install whisper
pip install carbon
pip install graphite-web
pip install django-tagging
# Carbon cache - the thing that you throw numbers at
cd /opt/graphite/conf
mv carbon.conf.example carbon.conf
mv storage-schemas.conf.example storage-schemas.conf
mv /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
cd /opt/graphite/bin
./carbon-cache.py start
wget -O /etc/apache2/sites-available/000-default.conf https://gist.githubusercontent.com/andrewmichaelsmith/9565983/raw/8e189ae32e7fe8f536719e49201e0470991ef5db/000-default.conf
cd /opt/graphite/webapp/graphite
python manage.py syncdb
chown -R www-data:www-data /opt/graphite/storage
/etc/init.d/apache2 restart
# ADD REQUIRE ALL GRANTED TO APACHE CONFIG
# <Directory /opt/graphite/conf/>
# Order deny,allow
# Allow from all
# Require all granted
# </Directory>
AND for /location
Alias /content/ /opt/graphite/webapp/content/
<Location "/content/">
SetHandler None
Order deny,allow
Allow from all
Require all granted
</Location>
# You might need to do this but I think you might have set it up already
python manage.py createsuperuser
mkdir /opt/grafana
cd /opt/grafana
wget https://github.com/torkelo/grafana/releases/download/v1.5.1/grafana-1.5.1.tar.gz
tar xfzv grafana-1.5.1.tar.gz
chown -R www-data:www-data /opt/grafana
#change config.js to point to localhost:80 instead of window.location.domain:8080
#put this in apache available sites
wget -O /etc/apache2/sites-available/001-grafana.conf https://gist.githubusercontent.com/andrewmichaelsmith/9565983/raw/ca517006fe419dcba6907063d2f45602d24f472d/001-grafana.conf
mkdir /etc/apache2/run/
chown -R www-data:www-data etc/apache2/run/
/etc/init.d/apache2 restart
a2ensite 001-grafana
##
# In /opt/graphite/webapp/graphite/local_settings.py set TIMEZONE = 'UTC'
#
#
####################################
# SEND DATA TO GRAPHITE
####################################
cd /opt/graphite/examples
sudo chmod +x example-client.py
# [optional] edit example-client.py to report data faster
# sudo vim example-client.py
sudo ./example-client.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment