Registrations for the November 2021 System Design Cohort are now open Enroll Today

Setting up Graphite and Grafana on an Ubuntu server

Published on 14th Dec 2015

3 min read

Share this article on

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.

If my work adds value, consider supporting me

Buy Me A Coffee

Arpit's Newsletter

2000+ Subscribers

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 articles that you might like

HTTP Requests using Netcat

HTTP Requests using Netcat

All our lives we have been hitting REST APIs with libraries and utilities like curl and postman. Its...

5th Jul
Multiple MySQL server running on same Ubuntu server

Multiple MySQL server running on same Ubuntu server

Have multiple MySQL versions running on same server within 5 minutes....

13th May
Benchmark Pagination Strategies in MongoDB

Benchmark Pagination Strategies in MongoDB

Benchmark results for two pagination approaches for MongoDB....

2nd Jun
Setting up Graphite using Nginx on an Ubuntu server

Setting up Graphite using Nginx on an Ubuntu server

Part 1: Monitor your production systems and application analytics using Graphite. This article will ...

14th Dec