Last active
April 19, 2017 18:02
-
-
Save jdeniau/5254228 to your computer and use it in GitHub Desktop.
Install Graphite in a virtualenv (python2.7) with apache and StatsD (Debian Squeeze)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create the virtualenv and work on it | |
mkvirtualenv graphite | |
workon graphite | |
cd $VIRTUAL_ENV # we are now in /home/envs/graphite/ . If you are not, you may have a problem with your virtualenv | |
# apparently you have to make a symlink because cairo does not work with python 2.7 and pip | |
# my cairo module was located on /usr/lib/pymodules/python2.7/cairo Check this path, it may change on your server. | |
# You can execute `locate cairo` to find out. | |
# if this step does not work, you will not have any graphics in graphite later | |
ln -s /usr/lib/pymodules/python2.7/cairo ./lib/python2.7/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create the directory | |
mkdir /opt/graphite | |
# make directory writable by whoever your want. You can chmod 777 if you want to: sudo chmod 777 /opt/graphite | |
# in our exemple, the "users" group, and www-data user (who execute apache) will have write and execute rights | |
sudo setfacl -dR -m m:rwx -m u:www-data:rwx -m g:users:rwx /opt/graphite | |
sudo setfacl -R -m m:rwx -m u:www-data:rwx -m g:users:rwx /opt/graphite | |
# install all required packages | |
pip install django==1.3 # Graphite does not seems to work with django >= 1.4 | |
pip install django-tagging twisted whisper carbon graphite-web # all other graphite dependancies | |
# configure graphite | |
cd /opt/graphite/conf/ | |
cp graphite.wsgi.example graphite.wsgi | |
cp carbon.conf.example carbon.conf | |
cp storage-schemas.conf.example storage-schemas.conf | |
# Edit graphite.wsgi in order to specify python virtualenv path | |
# Change the "import" line with those two lines : | |
- import os, sys | |
+ import os, sys, site | |
+ site.addsitedir('/home/envs/graphite/lib/python2.7/site-packages') | |
# Edit storage-schemas.conf in order to include a custom tweak provided by stats.d | |
[stats] | |
pattern = ^stats.* | |
retentions = 10:2160,60:10080,600:262974 | |
[carbon] | |
pattern = ^carbon\. | |
retentions = 60:90d | |
[default_1min_for_1day] | |
pattern = .* | |
retentions = 60s:1d | |
# Create a storage-aggregation.conf file | |
vim storage-aggregation.conf | |
# Then copy paste in it the following parameters | |
[min] | |
pattern = \.min$ | |
xFilesFactor = 0.1 | |
aggregationMethod = min | |
[max] | |
pattern = \.max$ | |
xFilesFactor = 0.1 | |
aggregationMethod = max | |
[sum] | |
pattern = \.count$ | |
xFilesFactor = 0 | |
aggregationMethod = sum | |
[default_average] | |
pattern = .* | |
xFilesFactor = 0.3 | |
aggregationMethod = average | |
# go back to the installation process | |
cd /opt/graphite/webapp/graphite | |
python manage.py syncdb # I spend some hour on this command, but if you have followed the previous steps, it should be working | |
# If you have some gcc error message, you may have to install python header | |
# enable graphite host | |
/opt/graphite/bin/carbon-cache.py start # errors can be found in /opt/graphite/storage/log/carbon-cache/ but I did not have any on that one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName graphite.example.com | |
ServerAlias graphite.example.com | |
DocumentRoot "/opt/graphite/webapp" | |
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} | |
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride All | |
</Directory> | |
Alias /content/ /opt/graphite/webapp/content/ | |
<Location "/content/"> | |
SetHandler None | |
</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 will not | |
# be visible to clients because of the DocumentRoot though. | |
<Directory /opt/graphite/conf/> | |
Order deny,allow | |
Allow from all | |
</Directory> | |
</VirtualHost> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
graphitePort: 2003 | |
, graphiteHost: "127.0.0.1" | |
, port: 8125 | |
, backends: [ "./backends/graphite", "./backends/console" ] | |
, debug: true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
graphitePort: 2003 | |
, graphiteHost: "127.0.0.1" | |
, port: 8125 | |
, backends: [ "./backends/graphite" ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment