How to install Graphite on Amazon Linux 7

For those of you that are not familiar with Graphite, it is an open source and scalable real-time graphing system.  It is very powerful for the simple fact that you can send any kind of metric its way at a regular interval and it performs all of the ‘magic’ behind the scenes to generate graphs of all types on demand.

I was recently tasked with a project that required Graphite to run on Amazon Linux (a derivative from RHEL / CentOS).  My only complaint with the Graphite system is the lack of how-to tutorials, etc. on how to get it up and running.  Thus, the reason for this post!  So without further ado, I will detail the steps I used to get a fully installed and functional Graphite system on Amazon Linux!

Note:  These steps are based upon Amazon Linux AMI 2013.03.

Prerequisites:

  • Run these commands as the root user (you need to log into your instance as ec2-user, then ‘sudo -i’ over to root)
  • Ensure your instance’s hostname is the way you want it before proceeding

Procedure:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
yum groupinstall -y "Development tools"
yum install -y --enablerepo=epel python-devel.noarch pycairo.x86_64 Django.noarch django-tagging.noarch python-twisted.noarch python-zope-interface.x86_64 fontconfig.x86_64 fontconfig-devel.x86_64 mod_wsgi.x86_64 python-pip.noarch pytz pyparsing python-memcached memcached
 
mkdir /usr/local/graphite
cd /usr/local/graphite
 
git clone https://github.com/graphite-project/graphite-web.git
git clone https://github.com/graphite-project/carbon.git
git clone https://github.com/graphite-project/whisper.git
git clone https://github.com/graphite-project/ceres.git
 
pushd whisper
python setup.py install
popd
 
pushd carbon
python setup.py install
popd
 
pushd ceres
python setup.py install
popd
 
pushd /opt/graphite/conf
cp carbon.conf.example carbon.conf
cp storage-schemas.conf.example storage-schemas.conf
popd
 
pushd graphite-web
python setup.py install
popd
 
cd /etc/httpd/conf.d/
cp /opt/graphite/examples/example-graphite-vhost.conf ./graphite-vhost.conf
 
sed -i "s/ServerName\ graphite/ServerName\ $(hostname -s)/g" ./graphite-vhost.conf
 
cd /opt/graphite/webapp/graphite
 
python manage.py syncdb

At this point you will be prompted to create a Django superuser.  Type ‘yes’, leave username blank to use ‘root’, enter a valid e-mail address, then type in a password for this user (twice).

1
2
3
4
5
6
7
8
chown apache:apache /opt/graphite/storage/graphite.db
 
cd /opt/graphite/conf/
cp graphite.wsgi.example graphite.wsgi
chown -Rh apache:apache /opt/graphite/storage
 
cd /opt/graphite/
./bin/carbon-cache.py start

Create /etc/init.d/carbon (file contents found below), then ‘chmod 755 /etc/init.d/carbon’ and ‘chkconfig carbon on’.  (I cannot take credit for the carbon init script, however, I also could not find the original author.)

You should now have a fully functional Graphite installation. Simply navigate to http://<hostname>/ and you should be presented with the Graphite interface.

Stay tuned for more posts about Graphite… Enjoy!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
# Carbon (part of Graphite)
#
# chkconfig: 3 50 50
# description: Carbon init.d
. /etc/rc.d/init.d/functions
 
prog=carbon
RETVAL=0
 
start() {
echo -n $"Starting $prog: "
 
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py start
RETVAL=$?
 
if [ $RETVAL = 0 ]; then
success "carbon started"
else
failure "carbon failed to start"
fi
 
echo
return $RETVAL
}
 
stop() {
echo -n $"Stopping $prog: "
 
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py stop &gt; /dev/null 2&gt;&amp;1
RETVAL=$?
 
if [ $RETVAL = 0 ]; then
success "carbon stopped"
else
failure "carbon failed to stop"
fi
 
echo
return $RETVAL
}
 
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py status
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 1
esac
 
exit $RETVAL