How to set up Graphite and Grafana on an Ubuntu server

Monitor your production systems and application analytics using Grafana and Graphite. This article will help you setup these tools on Ubuntu 14.04 on a Nginx webserver with PostgreSQL as backend.

Before starting following this setup, please go through my previous post on Deploy Graphite and Nginx on an Ubuntu 14.04 server

What is what

What is Grafana?

Grafana is a tool for visualising time-series data for various application analytics. It is a great tool when used in combination with Graphite. It gives us flexibility of creating dashboards and share them with teams. Grafana Official

Installing Graphite

To install Graphite please follow this tutorial on Deploy Graphite and Nginx on an Ubuntu 14.04 server.

Installing Grafana

Install Ubuntu Packages

Executing following commands will install Grafana on your machine

echo 'deb wheezy main' |  sudo tee -a /etc/apt/sources.list
curl | sudo apt-key add -
sudo apt-get update
sudo apt-get install grafana

Create a database for Grafana

Just as we created the database for Graphite on PostgreSQL, we will create a database for Grafana as well. Create a database grafana and give user graphite (the user having access to Graphite database) ownership of it.

$ CREATE DATABASE grafana WITH OWNER graphite;

Configure Grafana

Edit the Grafana configuration file

sudo vim /etc/grafana/grafana.ini

The settings should be something like this

type = postgres
host =
name = grafana
user = graphite
password = mypassword

protocol = http
http_addr =
http_port = 3000
domain =
enforce_domain = true
root_url = %(protocol)s://%(domain)s/

admin_user = admin
admin_password = your_secure_password
secret_key = your_random_secret_salt

Once your configuration is done, you can start Grafana Server by running

sudo service grafana-server start

The log files are located at /var/log/grafana/grafana.log

If everything goes well the log file should have content

$ tail /var/log/grafana/grafana.log

[1]: default.paths.logs=/var/log/grafana
  home: /usr/share/grafana
  data: /var/lib/grafana
  logs: /var/log/grafana

2015/12/16 06:37:15 [I] Database: postgres
2015/12/16 06:37:15 [I] Migrator: Starting DB migration
2015/12/16 06:37:15 [I] Listen:

Setup Nginx for Graphite

Let us first create all files and links

sudo touch /etc/nginx/sites-enabled/grafana
sudo ln -s /etc/nginx/sites-enabled/grafana /etc/nginx/sites-available/grafana

# Log files
sudo touch /var/log/nginx/grafana.access.log
sudo chmod 666 /var/log/nginx/grafana.access.log
sudo touch /var/log/nginx/grafana.error.log
sudo chmod 666 /var/log/nginx/grafana.error.log

Now we are ready for configuring Nginx server for Grafana

Open file /etc/nginx/sites-enabled/grafana and put following content in it

sudo vim /etc/nginx/sites-enabled/grafana

Nginx configuration

server {
  listen 80;

  rewrite ^(.*) https://$host$1 permanent;

server {

  listen 443 ssl spdy;

  access_log /var/log/nginx/grafana.access.log;
  error_log  /var/log/nginx/grafana.error.log;

  location = /robots.txt {
    echo "User-agent: *\nDisallow: /\n";

  location / {
    proxy_pass         http://localhost:3000;
    proxy_set_header   Host $host;


Now you can view a working Grafana on your server. Just hit from your favourite browser.

See it working

Once you open the Grafana page, you will see a page something like this.

Grafana 1

Log in to the system with default credentials

  • username: admin
  • password: admin

Once you are logged in, you should see a screen like this.

Grafana 2

Before you see any analytics information here, you should add your data source. The data source you will add will be Graphite that was setup earlier.

Goto Data Source -> Add New

Make following changes:

  • Name: graphite
  • URL:

You should test your connection before adding any dashboard.

Grafana 3

Once the connection is successful, now we are ready to add our first dashboard. Go to home page and goto New Dashboard -> New

Once that is done, you can add panels to it. To add graphs in panels click on Green Button -> Add Panel -> Graph. At the botton you will see metrics in which select test and count. Then you will see screen something like this.

Grafana 4

More Information

Please follow the below links in order to know more about Grafana and its amazing customizations.

Courses I teach

Alongside my daily work, I also teach some highly practical courses, with a no-fluff no-nonsense approach, that are designed to spark engineering curiosity and help you ace your career.

System Design Masterclass

A no-fluff masterclass that helps experienced engineers form the right intuition to design and implement highly scalable, fault-tolerant, extensible, and available systems.

Details →

System Design for Beginners

An in-depth and self-paced course for absolute beginners to become great at designing and implementing scalable, available, and extensible systems.

Details →

Redis Internals

A self-paced and hands-on course covering Redis internals - data structures, algorithms, and some core features by re-implementing them in Go.

Details →

Arpit Bhayani

Arpit's Newsletter

CS newsletter for the curious engineers

❤️ by 80000+ readers

If you like what you read subscribe you can always subscribe to my newsletter and get the post delivered straight to your inbox. I write essays on various engineering topics and share it through my weekly newsletter.

Arpit's Newsletter read by 80000+ engineers

Weekly essays on real-world system design, distributed systems, or a deep dive into some super-clever algorithm.