Thursday, May 22, 2014

Install and config Graphite on Debian/Ubuntu

Install graphite server using python-pip

apt-get install gcc python-dev python-pip

sudo pip install
sudo pip install whisper
sudo pip install carbon
sudo pip install graphite-web

cd /opt/graphite/conf
sudo cp carbon.conf.example carbon.conf
sudo cp storage-schemas.conf.example storage-schemas.conf
sudo cp graphite.wsgi.example graphite.wsgi


Run carbon service and test


sudo /opt/graphite/bin/ start

if you get something like Python Error - ImportError: cannot import name daemonize
take a look at: Can't Start Carbon - 12.04 - Python Error - ImportError: cannot import name daemonize
sudo pip install 'Twisted<12.0'

check if the port of carbon service is opened:
netstat -naep | grep 2003

perl -e '$ts = time(); for (1..1000) { printf " %d %d\n", int(rand(10000)), $ts - 90 * $_ }' \ | nc -c localhost 2003


Run Graphite web UI (apache2 with mod_python, mod_wsgi)


sudo apt-get install apache2 libapache2-mod-python libapache2-mod-wsgi

sudo chown -R www-data:www-data /opt/graphite/storage/

sudo mv /etc/apache2/sites-available/default /etc/apache2/sites-available/default.bak
sudo cp /opt/graphite/examples/example-graphite-vhost.conf /etc/apache2/sites-available/default
sudo mkdir /etc/httpd
sudo mkdir /etc/httpd/wsgi

cd /opt/graphite/webapp/graphite/
sudo cp

restart apache2
sudo service apache2 restart


Initialize database after installed apache2


sudo apt-get install python-django
sudo pip install django-tagging==0.3.1

cd /opt/graphite/webapp/graphite/
sudo python syncdb
Username: root
Password: xxx

TIME_ZONE = 'Europe/Berlin'




1) Edit the following file:

Make sure that the configuration for WSGISocketPrefix is set as follows:
WSGISocketPrefix /var/run/apache2/wsgi

Otherwise, you will get the following error:

    [Tue Jun 19 13:21:28 2012] [error] [client] (2)No such file or directory: mod_wsgi (pid=19506): Unable to connect to WSGI daemon process 'graphite' on '/etc/apache2/run/wsgi.19365.1.1.sock' after multiple attempts.

2) if you changed the VirtualHost post, do not forget to add this port in
add something like this:
NameVirtualHost *:8000
Listen 8000

3) if you can not see the images, get something like this:
ViewDoesNotExist: Could not import graphite.render.views. Error was: No module named cairo

you need install:
sudo apt-get install python-cairo-dev

4) watch the logs if something still not working right:
cd /opt/graphite/storage/log/webapp
find . -name '*.log' | xargs tail -F

5) location of graphite's whisper database (RDD storage)


example: storage-schemas.conf


pattern = ^stats_1day\.
retentions = 1d:1y

pattern = ^stats_1hour\.
retentions = 1h:90d


example: /etc/apache2/sites-available/default


<IfModule !wsgi_module.c>
    LoadModule wsgi_module modules/

WSGISocketPrefix /var/run/apache2/wsgi

<VirtualHost *:8000>
        ServerName graphite
        DocumentRoot "/opt/graphite/webapp"
        ErrorLog /opt/graphite/storage/log/webapp/error.log
        CustomLog /opt/graphite/storage/log/webapp/access.log common

        # enable XORS (Cross-origin resource sharing), see below
        Header set Access-Control-Allow-Origin "*"

        # 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

        # 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

        # 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


you may want to enable XORS (Cross-origin resource sharing) or cross site scripting or whatever~

you should add this line
Header set Access-Control-Allow-Origin "*"
in to

and then restart apache2




there is a small bug in Graphite's Dashboard JS, take a look this post:


  1. show loaded modules:

    apachectl -t -D DUMP_MODULES

  2. The Assam Higher Secondary Education Council was established on 1st June,1984.Assam Higher Secondary Education Council or AHSEC is renowned board for 10+2 education in north-eastern India. The AHSEC have its head Office at AHSEC HS Question Paper 2023 Bamunimaidam, Guwahati. It regulate, supervise and develop Higher Secondary Education in the state of Assam.


© Chutium / Teng Qiu @ ABC Netz Group