Graphite is a scalable metric graphing solution. It’s a popular choice in the enterprise for collecting metrics from multiple sources and producing readable graphs. However, Graphite’s graphing interface isn’t all that user friendly and it’s difficult to showcase the collected metrics. This is where Grafana shines. Grafana is a web front-end for Graphite or InfluxDB. Although they have their own graphing solutions, Grafana is far more powerful and much easier to use. I’ll guide you through installing and configuring Graphite and Grafana on Ubuntu 14.04.
Run the following command to perform all updates and upgrades to Ubuntu.
sudo apt-get update && sudo apt-get upgrade
The following command will install Graphite as well as the prerequisites.
Note: During the installation of graphite-carbon, you will be asked if you want to remove the whisper database files should you ever uninstall Graphite. Answer No to this prompt. You can always remove the files later (which are located in /var/lib/graphite/whisper).
sudo apt-get install build-essential graphite-web graphite-carbon python-dev apache2 libapache2-mod-wsgi libpq-dev python-psycopg2
sudo nano /etc/default/graphite-carbon
CARBON_CACHE_ENABLED=true
sudo service carbon-cache start
By default Graphite will use SQLite. PostgreSQL is much more robust.
sudo apt-get install postgresql
sudo su postgres
createuser graphite --pwprompt
createdb -O graphite graphite createdb -O graphite grafana
su - youruseraccountname
There are a few configuration changes that need to be made to Graphite.
sudo nano /etc/graphite/local_settings.py
DATABASES = { 'default': { 'NAME': 'graphite', 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'USER': 'graphite', 'PASSWORD': 'graphite', 'HOST': '127.0.0.1', 'PORT': '' } }
TIME_ZONE = 'America/Edmonton'
SECRET_KEY = 'WH@T3v3RuW@nTG03$h3Re'
sudo graphite-manage syncdb
Apache is required for Graphite.
sudo cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-available
sudo nano /etc/apache2/sites-available/apache2-graphite.conf
Change the following line from port 80 to 8080:
<VirtualHost *:8080>
sudo nano /etc/apache2/ports.conf
Add port 8080. For example:
Listen 80 Listen 8080
sudo a2dissite 000-default
sudo a2ensite apache2-graphite
sudo service apache2 reload
The following will outline how to install Grafana on Ubuntu.
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo apt-get update && sudo apt-get install grafana
sudo nano /etc/grafana/grafana.ini
Update the database connection values to use PostgreSQL. For example:
[database] type = postgres host = 127.0.0.1:5432 name = grafana user = graphite password = graphite
Update the server configuration. For example:
[server] protocol = http http_addr = 127.0.0.1 http_port = 3000 domain = domain.com enforce_domain = true root_url = %(protocol)s://%(domain)s/
Update the security information. For example:
[security] # default admin user, created on startup admin_user = admin # default admin password, can be changed before first start of grafana, or in profile settings admin_password = admin # used for signing secret_key = SW2YcwsfssfsDSFDS8979869t
Enable anonymous viewing.
[auth.anonymous] # enable anonymous access enabled = true
sudo a2enmod proxy proxy_http xml2enc
sudo nano /etc/apache2/sites-available/apache2-grafana.conf
Add the following to the file (replace “domain.com” with your domain):
ProxyPreserveHost On ProxyPass / http://127.0.0.1:3000/ ProxyPassReverse / http://127.0.0.1:3000/ ServerName domain.com
sudo a2ensite apache2-grafana
sudo update-rc.d grafana-server defaults 95 10
sudo service grafana-server start
sudo service apache2 restart
Adding a data source to Grafana is fairly straight forward.
There are many ways to send data to Graphite. Many monitoring solutions will have the option to send metrics to Graphite. If you use VMware, you can send vCenter statistics to Graphite/Grafana with using a PowerShell script.
Once you have metrics in Graphite, you can begin graphing. Below is a video from the Grafana YouTube channel which includes steps for creating a dashboard and a graph.
View Comments