(Last Updated On: March 2, 2019)

This is a guide on How to Install Grafana on Ubuntu 18.04 and Debian 9. Earlier on our infrastructure and systems monitoring series, we covered Installation of Grafana on CentOS 7 server. Then later demonstrated how to monitor Linux systems with Grafana, telegraf, and InfluxDB.

A good infrastructure/systems monitoring can help you avoid a 3 am call by preventing issues from arising.  There are different monitoring tools available, and choosing the right one can be challenging. Also look at How to Install Zabbix Server on Ubuntu 18.04.

What is Grafana?

Grafana is an open source, feature rich metrics dashboard and graph editor for Graphite, Elasticsearch, OpenTSDB, Prometheus, and InfluxDB. As an example, when using InfluxDB as your data source, data stored on InfluxDB will be visualized using Grafana Graphs.

How to Install Grafana on Ubuntu 18.04

There are two common ways to Install Grafana on Ubuntu 18.04:

  • Using the official APT repository
  • Installing from .deb package

The preferred method is using apt repository since you can easily upgrade to the latest release using the apt package manager for Debian and Ubuntu.

Method 1: Installing Grafana on Ubuntu 18.04 / Debian 9 using APT repository

Add the following line to /etc/apt/sources.list.d/grafana.list

echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list

For beta packages, add:

echo "deb https://packages.grafana.com/oss/deb beta main" | sudo tee /etc/apt/sources.list.d/grafana.list

Then add the Package Cloud key. This allows you to install signed packages.

curl https://packages.grafana.com/gpg.key | sudo apt-key add - 

Update apt index and install grafana on Ubuntu 18.04 / Debian 9:

sudo apt-get install -y apt-transport-https grafana

Start and enable grafana-server service to start on boot:

sudo systemctl enable --now grafana-server

Check status to confirm that it is running:

$ systemctl status grafana-server.service
● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-03-02 07:59:24 CET; 23s ago
Docs: http://docs.grafana.org
Main PID: 24336 (grafana-server)
Tasks: 8 (limit: 2299)
CGroup: /system.slice/grafana-server.service
└─24336 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=deb cfg:default
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing QuotaService" logger=server
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing ServerLockService" logger=server
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing UserAuthTokenService" logger=server
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing CleanUpService" logger=server
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing NotificationService" logger=server
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing ProvisioningService" logger=server
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing TracingService" logger=server
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="Initializing Stream Manager"
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="HTTP Server Listen" logger=http.server address=0.0.0.
Mar 02 07:59:25 ubuntu-2gb-nbg1-1 grafana-server[24336]: t=2019-03-02T07:59:25+0100 lvl=info msg="cleanup of expired auth tokens done" logger=auth coun

Open Port on Firewall

Grafana default http port is 3000, you’ll need to allow access to this port on the firewall. Ubuntu comes with ufw firewall. For Debian, you can install it using:

sudo apt-get install ufw

Then enable the firewall service:

sudo ufw enable

Open the port on the firewall:

sudo ufw allow 3000/tcp

To allow access only from a specific subnet, use:

sudo ufw allow from 192.168.50.0/24 to any port 3000

Accessing Grafana Dashboard

Access Grafana Dashboard using the server IP address or hostname and port 3000.

Default logins are:

Username: admin
Password: admin

Change Admin Password

Remember to change admin password from default admin. Login and navigate to:

Preferences > Change Password

Grafana Package details:

  • Installs binary to /usr/sbin/grafana-server
  • Installs Init.d script to /etc/init.d/grafana-server
  • Creates default file (environment vars) to /etc/default/grafana-server
  • Installs configuration file to /etc/grafana/grafana.ini
  • Installs systemd service (if systemd is available) name grafana-server.service
  • The default configuration sets the log file at /var/log/grafana/grafana.log
  • The default configuration specifies a sqlite3 db at /var/lib/grafana/grafana.db
  • Installs HTML/JS/CSS and other Grafana files at /usr/share/grafana

The systemd service file and init.d script both use environment vars on the file located at /etc/default/grafana-server.

Next steps include looking at Adding data sources

Other monitoring guides:

Monitoring Ceph Cluster with Prometheus and Grafana

How to Monitor Redis Server with Prometheus and Grafana in 5 minutes

How to Monitor Linux Server Performance with Prometheus and Grafana in 5 minutes

How to Monitor BIND DNS server with Prometheus and Grafana

Monitoring MySQL / MariaDB with Prometheus in five minutes

How to Monitor Apache Web Server with Prometheus and Grafana in 5 minutes