Graphite does two things:
- Store numeric time-series data
- Render graphs of this data on demand
What Graphite does not do is collect data for you, however there are some tools out there that know how to send data to graphite. Even though it often requires a little code, sending data to Graphite is very simple.
Architecture:
Graphite consists of 3 software components:
- carbon - a Twisted daemon that listens for time-series data
- whisper - a simple database library for storing time-series data (similar in design to RRD)
- graphite webapp - A Django webapp that renders graphs on-demand using Cairo
Installing dependencies:
curl -o epel.rpm -L http://download.fedoraproject.org/pub/epel/6/$(arch)/epel-release-6-8.noarch.rpm
yum install gcc zlib-devel curl curl-devel openssl rpm-build gcc-c++ rpm-build python python-ldap python-memcached python-sqlite2 pycairo python-twisted Django python-django-tagging bitmap bitmap-fonts python-devel glibc-devel gcc-c++ openssl-devel python-zope-interface httpd memcached mod_wsgi wget
Install whisper, as both Carbon and Graphite require it
wget https://launchpad.net/graphite/0.9/0.9.10/+download/whisper-0.9.10.tar.gz
tar zxf whisper-0.9.10.tar.gz
cd whisper-0.9.10/
sudo python2.6 setup.py install
cd ..
Install carbon
wget https://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gz
tar zxf carbon-0.9.10.tar.gz
cd carbon-0.9.10/
sudo python2.6 setup.py install
cd ..
```
Install graphite webapp
```
wget https://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gz
tar zxf graphite-web-0.9.10.tar.gz
cd graphite-web-0.9.10/
./check-dependencies.py
```
once all dependencies are met...
```
sudo python2.6 setup.py install
```
This will install whisper as a site package and carbon and graphite will be installed into `/opt/graphite`
Configuring:
```
cd /opt/graphite/conf/
cp graphite.wsgi.example graphite.wsgi
cp storage-schemas.conf.example storage-schemas.conf
cp carbon.conf.example carbon.conf
cd ../webapp/graphite
cp local_settings.py.example local_settings.py
```
Uncomment the database engine in `local_settings.py` and then initialize the database by running the following command
```
python /opt/graphite/webapp/graphite/manage.py syncdb
```
Configuring httpd and wsgi:
```
cat > /etc/httpd/conf.d/wsgi.conf <<EOF
LoadModule wsgi_module modules/mod_wsgi.so
WSGISocketPrefix /var/run/wsgi
EOF
```
```
cat > /etc/httpd/conf.d/graphite.conf <<EOF
<IfModule !wsgi_module.c>
LoadModule wsgi_module modules/mod_wsgi.so
</IfModule>
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:80>
ServerName $(hostname -f)
DocumentRoot "/opt/graphite/webapp"
ErrorLog /var/log/httpd/graphite_error.log
CustomLog /var/log/httpd/graphite_access.log common
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
Alias /content/ /opt/graphite/webapp/content/
<Location "/content/">
SetHandler None
</Location>
Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"
<Location "/media/">
SetHandler None
</Location>
<Directory /opt/graphite/conf/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
EOF
```
```
chown -R apache:apache /opt/graphite/storage/
/etc/init.d/httpd restart
```
```
cat > /etc/init.d/carbon-cache <<\EOF
#!/bin/bash
#
# This is used to start/stop the carbon-cache daemon
# chkconfig: - 99 01
# description: Starts the carbon-cache daemon
# Source function library.
. /etc/init.d/functions
RETVAL=0
prog="carbon-cache"
start_relay () {
/usr/bin/python /opt/graphite/bin/carbon-relay.py start
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
return $RETVAL
}
start_cache () {
/usr/bin/python /opt/graphite/bin/carbon-cache.py start
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
return $RETVAL
}
stop_relay () {
/usr/bin/python /opt/graphite/bin/carbon-relay.py stop
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
return $RETVAL
}
stop_cache () {
/usr/bin/python /opt/graphite/bin/carbon-cache.py stop
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start)
#start_relay
start_cache
;;
stop)
#stop_relay
stop_cache
;;
restart)
#stop_relay
stop_cache
#start_relay
start_cache
;;
*)
echo $"Usage: $0 {start|stop}"
exit 2
;;
esac
EOF
chmod +x /etc/init.d/carbon-cache
```
```
service memcached start
service carbon-cache start
service httpd start
```
Thanks so much for this!
Using CentOS 6.5 here and I had to do one step more -- change "client authentication" for PostrgreSQL (default was
ident
, this needs to bemd5
).I forked your gist and applied a change ( https://gist.github.com/kgadek/5d12511a4825d2489fcd/revisions ). Feel free to pull it back :)
--edit--
Introducing further changes (like: clean install of CentOS and
hostname -f
not working…)