Deploy Graphite with Grafana on Ubuntu 14.04

This is a Linode Community guide. If you’re an expert on something for which we need a guide, you too can get paid to write for us.

Set Up Graphite Monitoring Software with Grafana on Ubuntu

Graphite is an enterprise-level monitoring tool renowned for performing well on systems with limited resources. It stores numeric time-series data and renders graphs of this data on demand. This guide provides an introduction to the installation and basic setup of Graphite together with Grafana, a popular open source application for visualizing large-scale measurement data, on Ubuntu 14.04.

Before You Begin

Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.

This guide will use sudo wherever possible from an example account named graphite. Complete the sections of our Securing Your Server guide to create the graphite user, harden SSH access, remove unnecessary network services and set up a firewall. You may need to create additional firewall rules for your specific application.

Update your system:

sudo apt-get update && sudo apt-get upgrade

Install Apache, Python Tools and Graphite

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).

Configure Carbon

Configure the retention rate for test metrics by adding a [test] block to Carbon’s storage-schemas.conf file. This step is given for testing purposes only and can be safely skipped if you have no use to generate test metrics.

The retention times given below will save data every 5 seconds for 3 hours, and a separate set of data from that aggregated sample every 1 minute for 1 day.

storage-aggregation.conf describes aggregation policies Carbon uses to produce less detailed metrics, such as the 1m:1d retention in the [test] block added above. By default, only the average metric value is taken, which will result in data loss when, for example, you need maximum and minimum values. For this reason, [min],[max] and [sum] sections are found in the configuration file.

Enable Carbon’s cache to run on boot:

/etc/default/graphite-carbon

1

CARBON_CACHE_ENABLED=true

Start the Carbon cache service:

sudo service carbon-cache start

Install and Configure PostgreSQL

Install PostgreSQL for the graphite-web application:

sudo apt-get install postgresql

Change to the postgres user and create a database user for Graphite:

su - postgres
createuser graphite --pwprompt

You will be asked to provide a password for the new database user. After that, create the databases graphite and grafana with the system’s graphite user as the owner:

createdb -O graphite graphite
createdb -O graphite grafana

When finished configuring the PostgreSQL databases, change back to the graphite user:

su - graphite

Configure Graphite

Update Graphite’s DATABASES dictionary definition with the settings for the PostgreSQL database created earlier:

Configure Apache for Graphite

Change Graphite’s port from 80 to 8080 (port 80 will be used for Grafana later).

/etc/apache2/sites-available/apache2-graphite.conf

1

<VirtualHost*:8080>

Make sure Apache is listening on port 8080. Add Listen 8080 after Listen 80 in ports.conf:

/etc/apache2/ports.conf

12

Listen80Listen8080

Disable the default Apache site to avoid conflicts:

sudo a2dissite 000-default

Enable Graphite’s virtual site:

sudo a2ensite apache2-graphite

Reload Apache to apply the changes:

sudo service apache2 reload

Now you should be able to access Graphite by going to your Linode’s hostname or IP address using port 8080 in a web browser (ex: example_domain.com:8080). You’ll see the Graphite landing page as shown below:

Edit the Graph panel properties by clicking the tab with the words no title (click here). Then click Edit:

Make sure the graphite data source you’ve created is chosen in the dropdown box at the bottom right (marked as 1 in the screenshot below). In the dropdown at the top right corner (marked as 2), choose Last 15 minutes.

Click select metric. Choose test and then count (marked as 3) to add the test metric you previously created. At this point, the sample data should appear on the graph.

Finally, click the Save button (marked as 4) to save the dashboard you just created.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.