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

Arpit Bhayani

Arpit's Newsletter

CS newsletter for the curious engineers

❤️ by 21000+ 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.

Other essays that you might like

Designing Taxonomy on a Relational DB

1303 reads 2021-04-18

In this essay, design taxonomy on a SQL-based Relational database by taking Udemy as an example, write SQL queries cover...

The Weird Walrus

2377 reads 2021-03-29

In this essay, we alter the Python Grammar and allow it run Assignment Expressions without any parenthesis....

Stop an Iterating Loop

426 reads 2019-09-06

There are two ways through which we can stop an iterating loop, first by using break statement and second by making loop...

Sleepsort and Concurrency in Golang

460 reads 2017-07-16

Understanding concurrency in any programming language is tricky let alone Golang; hence to get my hands dirty the first ...

Be a better engineer

A set of courses designed to make you a better engineer and excel at your career; no-fluff, pure engineering.

Paid Courses

System Design Masterclass

A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.

1000+ learners

Details →

Redis Internals

Learn internals of Redis by re-implementing some of the core features in Golang.

46+ learners

Details →

Free Courses

Designing Microservices

A free playlist to help you understand Microservices and their high-level patterns in depth.

106+ learners

Details →

GitHub Outage Dissections

A free playlist to help you learn core engineering from outages that happened at GitHub.

251+ learners

Details →

Hash Table Internals

A free playlist to help you understand the internal workings and construction of Hash Tables.

427+ learners

Details →

BitTorrent Internals

A free playlist to help you understand the algorithms and strategies that power P2P networks and BitTorrent.

192+ learners

Details →

Topics I talk about

Being a passionate engineer, I love to talk about a wide range of topics, but these are my personal favourites.

  • v13.9.2
  • © Arpit Bhayani, 2022

Powered by this tech stack.