Grafana from the Ground Up

Grafana installation and setup

Grafana from the Ground Up

This quick step by step guide will get you up and running grafana within 20 minutes.
We will be using Ubuntu 18.04.3 (LTS) x64

Download and Install Grafana

Download Grafana
Grafana Feature overview, screenshots, videos, feature tours
# install libfontconfig1
apt-get install libfontconfig1
# download the grafana .deb
wget https://dl.grafana.com/oss/release/grafana_6.5.1_amd64.deb
# check sha256 checksum
sha256sum grafana_6.5.1_amd64.deb
# install the .deb
sudo dpkg -i grafana_6.5.1_amd64.deb
At the time of publishing the current version is 6.5.1

Configure Grafana

First change the CONF_FILE parameter. Once that is changed duplicate the grafana.ini file to match the new CONF_FILE parameter.

nano /etc/default/grafana-server
# OLD: CONF_FILE=/etc/grafana/grafana.ini
# NEW: CONF_FILE=/etc/grafana/myconfig.ini

# duplicate the file
cp /etc/grafana/grafana.ini /etc/grafana/myconfig.ini

# make sure grafana users can read the new file
chgrp grafana /etc/grafana/myconfig.ini

# edit the new config file
nano /etc/grafana/myconfig.ini
#################################### Security ####################################
[security]
# disable creation of admin user on first start of grafana
;disable_initial_admin_creation = false

# 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 = [change this]

# used for signing
secret_key = [change this]

Change the default admin password and the secret key.
Its also recommended that after logging in you change the admin password to something else.

Setup NGINX

Grafana by default listens on port 3000 on all interfaces.
Lets put it behind NGINX so we can have users use port 80/443

# install NGINX
apt-get install nginx

# add the grafana config (see example below)
nano /etc/nginx/sites-available/grafana

# enable the config
ln -s /etc/nginx/sites-available/grafana /etc/nginx/sites-enabled/grafana

# reload NGINX
systemctl reload nginx
server {
    listen 80;
    server_name hostname;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Note: This config example is not using HTTPS, a full guide on NGINX and HTTPS can be viewed HERE.

Start the grafana service

service grafana-server start

OPTIONAL: Tell Grafana to only listen on localhost. This will prevent users from directly hitting the grafana service on port 3000.

nano /etc/grafana/myconfig.ini
# The ip address to bind to, empty will bind to all interfaces
http_addr = 127.0.0.1
service grafana-server restart

Login to Grafana

Grafana login screen

Once logged in you can add a datasource to start visualizing data!

Just want to explore the program and don't care about the installation?
Digital Ocean has a 1 click install for grafana in the marketplace.

Grafana Hosting | DigitalOcean Marketplace 1-Click App
The leading open source platform for beautiful analytics and monitoring.

Get $100 in cloud credits from DigitalOcean using my link: https://m.do.co/t/909d52b6253a