I’ve been struggling a few days with installation of Graphite and Grafana. But finally it paid of to keep attacking the problem from different angels.

Here is a short description of how to manage this.

I used a VirtualBox VM Ubuntu 14 with bridged network connection to test this stack.

Components that will be installed are:

  1. Graphite
  2. Grafana
  3. Elasticsearch
  4. Collectd

So lets do it:

sudo -i
apt-get update
apt-get install -y graphite-carbon
echo "CARBON_CACHE_ENABLED=true" > /etc/default/graphite-carbon
service carbon-cache start
apt-get install -y graphite-web apache2 apache2-mpm-worker libapache2-mod-wsgi
chown _graphite /var/lib/graphite
sudo -u _graphite graphite-manage syncdb --noinput
rm -f /etc/apache2/sites-enabled/000-default.conf
cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-enabled/graphite.conf
service apache2 restart
curl -s http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -
echo "deb http://packages.elasticsearch.org/elasticsearch/1.0/debian stable main" > /etc/apt/sources.list.d/elasticsearch.list
apt-get update
apt-get install -y elasticsearch openjdk-7-jre-headless
update-rc.d elasticsearch defaults
curl -O -L http://grafanarel.s3.amazonaws.com/grafana-1.9.1.tar.gz
tar xf grafana-1.9.1.tar.gz
cp -R grafana-1.9.1 /usr/share/grafana
echo "alias /grafana /usr/share/grafana" > /etc/apache2/sites-enabled/grafana.conf
service apache2 restart
cd /usr/share/grafana/
cp config.sample.js config.js
vi config.js

Change YOUR_IP to the IP of your server

// Graphite & Elasticsearch example setup
datasources: {
graphite: {
type: ‘graphite’,
url: “http://YOUR_IP:80”,
},
elasticsearch: {
type: ‘elasticsearch’,
url: “http://YOUR_IP:9200/”,
index: ‘grafana-dash’,
grafanaDB: true,
}
},

vi /etc/elasticsearch/elasticsearch.yml

search for network.host: and change the line to be network.host: 0.0.0.0

apt-get install collectd 
vi /etc/collectd/collectd.conf

Uncomment the LoadPlugins that you want to monitor

LoadPlugin cpu
LoadPlugin memory
Most importantly LoadPlugin write_graphite

make sure to uncomment the configuration part for “<write_graphite>”

vi /etc/carbon/storage-schemas.conf

add:

[collectd]
pattern = ^collectd.*
retentions = 10s:1d,1m:7d,10m:1y

Now you should be set! Open your browser to YOUR_IP or YOUR_IP/grafana and enjoy!

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *