Graphite/Old2
From charlesreid1
Graphite is a system for collecting and plotting time-series data using MongoDB and Python.
Graphite was installed on Ethane following the guide on this page: http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
https://graphite.readthedocs.io/en/latest/index.html
Contents
Preparation
sudo apt-get update sudo apt-get upgrade
Now install some dependencies:
sudo apt-get install --assume-yes apache2 libapache2-mod-php5 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 python3.1 libpython3.1 python3.1-minimal libapache2-mod-wsgi libaprutil1-ldap memcached python-cairo-dev python-django python-ldap python-memcache python-pysqlite2 sqlite3 erlang-os-mon erlang-snmp rabbitmq-server bzr expect ssh libapache2-mod-python python-setuptools
sudo easy_install django-tagging
Installation
Graphite comes in three parts: Graphite (the web plotting frontend), Carbon (the data stream and database manager), and Whisper (the database interface).
Downloading Sources
https://github.com/downloads/graphite-project/graphite-web/graphite-web-0.9.10.tar.gz https://github.com/downloads/graphite-project/carbon/carbon-0.9.10.tar.gz https://github.com/downloads/graphite-project/whisper/whisper-0.9.10.tar.gz
Untar Sources
Run tar xzf filename.tar.gz
and run sudo python setup.py install
to install each package into the default location - /opt/graphite
.
Followed the step-by-step here: http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
Graphite finally running, was able to successfully send stuff to Carbon and have it successfully put stuff in a whisper database. However, no idea how to get to actual plots with Graphite's web app frontend.
Errors
I had to work through a bunch of errors to get things working smoothly.
This error:
ImportError: No module named defaults
was resolved with this: http://stackoverflow.com/questions/19962736/django-import-error-no-module-named-django-conf-urls-defaults
I installed Django 1.5 (instead of the default 1.6) using:
pip install django==1.5
Next I had to deal with the name
ImportError: cannot import name parse_lookup
This was resolved following http://greenlegos.wordpress.com/2012/09/09/graphite-installation/, which involves following these instructions https://groups.google.com/forum/#!msg/django-users/vzxb6y2IewE/8jHyJC1RIkkJ to get a newer version of Django-tagging installed.
Next, I was able to restart my apache server and go to the port where the Graphite virutalhost is hosted, but I was getting a Python error message on the screen:
Invalid HTTP_HOST header set ALLOWED_HOSTS
This was resolved following http://stackoverflow.com/questions/15238506/djangos-suspiciousoperation-invalid-http-host-header
Really easy, just had to uncomment out the DATABASES dictionary
Then I had to deal with this error:
settings.DATABASES is improperly configured
which I resolved following http://stackoverflow.com/questions/9850581/django-error-when-installing-graphite-settings-databases-is-improperly-configu
Finally, I got this error:
DatabaseError: no such table: auth_user
which I managed to resolve following https://answers.launchpad.net/graphite/+question/187148
Easy as
cd /opt/graphite/webapp/graphite/ python ./manage.py syncdb
Success
Once successful, I see this page when I go to http://localhost:8008 (or whatever host I've defined):
Graphite and Cubism
To get Graphite and Cubism to talk together, I used this page: http://cookingclouds.com/2012/12/18/cubism-js-with-graphite-server/
This page describes how to create a simple Cubism plot using Graphite data.
Create a file in opt/graphite/webapp/content/html/test.html
(reason: your Cubism requests (to Graphite) must come from the same IP address AND port number as the Graphite server, otherwise you'll get a site cross-scripting error; by putting it in your graphite content directory, you can ensure that you are accessing your Cubism test it from the same IP and port number as the Graphite server.)
In my case, I was running Graphite on port 8008, so I needed to do the above so my test.html would be creating its requests from port 8008 (instead of port 80, which would be the origin of the requests if I put it in my normal Apache directory.)
The file test.html is straightforward. It consists of loading javascript libraries (Cubsim and D3), then specifying the location of the Graphite server and what data sets to load from Graphite, then some modifications made to the D3 plots.
Here's the full, final file:
<html> <style> @import url(//fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,700); @import url(//square.github.com/cubism/style.css); </style> <div id="body"> <h2>Host01 Load Average</h2> <div id="graphs"></div> <script type="text/javascript" src="http://d3js.org/d3.v2.js"></script> <script type="text/javascript" src="http://square.github.com/cubism/cubism.v1.js"></script> <script type="text/javascript" src="http://square.github.com/cubism/highlight.min.js"></script> <script type="text/javascript"> var context = cubism.context() .step( 1 * 60 * 1000 ) // 1 minute .size(960); // 1 * 960 = 4 hours var graphite = context.graphite("http://localhost:8008"); //var horizon = context.horizon().metric(graphite.metric).height(100).shift( - 0 * 24 * 60 * 60 * 1000 ); var horizon = context.horizon().metric(graphite.metric).height(100) var metrics = [ 'system.loadavg_1min', 'system.loadavg_5min', 'system.loadavg_15min' ] d3.select("#graphs").append("div") .attr("class", "axis") .call(context.axis().orient("top")); d3.select("#graphs").append("div") .attr("class", "rule") .call(context.rule()); d3.select("#graphs").selectAll(".horizon") .data(metrics) .enter().append("div") .attr("class", "horizon") .call(horizon); </script> </html>
This results in the following: