How to Install Grafana on Linux Servers

On this page

Grafana is an open source data visualization and monitoring suite. It offers support for Graphite, Elasticsearch, Included, Prometheus, and many more databases. The tool provides a beautiful dashboard and metric analytics, with ability to manage and create your own dashboard for your apps or infrastructure performance monitoring.

In this tutorial, we will show you how to install and configure Grafana on Linux servers (Ubuntu 16.04 and CentOS 7). We'll be installing Grafana on both servers using the Grafana repository, and after the installation, we will guide you how to add and install Grafana plugins.

Prerequisites

Ubuntu Server 16.04 or CentOS 7.

Root privileges

What we will do

Install Grafana on Ubuntu 16.04

Install Grafana on CentOS 7

Change Grafana admin password

Install Grafana plugins

Step 1 - Install Grafana on Ubuntu 16.04

Grafana provides two ways for installation - using the downloaded Debian package and using the apt repository. In this tutorial, we will be using apt repository installation. So let's begin.

Now, update repository and install Grafana using the following apt commands.

sudo apt updatesudo apt install grafana

After the installation is complete, you will get the result as shown below.

As you might know, Ubuntu 16.04 uses systemd as the init system. So, after the Grafana installation we need to reload systemd manager configuration, in order to start Grafana service.

systemctl daemon-reload

Start Grafana and enable it to run automatically at system boot everytime.

systemctl start grafana-serversystemctl enable grafana-server

By default, Grafana will run under port 3000. Check it using the netstat command and make sure that the port 3000 is on the 'LISTEN' state list.

netstat -plntu

If you have the UFW firewall installed on the server, open the ssh service port, grafana port 3000, and then start the firewall using the following commands.

ufw allow sshufw allow 3000/tcpufw enable

Type 'y' to continue to start and add UFW to run automatically at boot time.

To see the firewall status, run the command below.

ufw status

Grafana has been installed on Ubuntu 16.04 server, and it's running under the UFW Firewall Ubuntu on port 3000.

Step 2 - Install Grafana on CentOS 7

In this step, we will show you how to install Grafana from the repository on a CentOS 7 server. We can install Grafana through the rpm package or the repository. For this guide, we will be using the Grafana repository.

Add new Grafana repository by creating a new .repo file in the 'yum.repos.d' directory. Go to the directory and create a new file dubbed 'grafana.repo' using the vim editor.

Step 3 - Change Grafana admin password

Log in to the Grafana Dashboard using default user 'admin' and password 'admin'.

You will see Grafana Dashboard as shown below.

To change the default username and password for Grafana, click on the Grafana logo on the top left and then click the 'Admin' menu, then choose the 'Global Users'.

You will see the list of users. Click on 'Edit' menu to edit the username and password.

Type your new username and password, click on the green 'Update' button to confirm.

Grafana default user and password has been changed.

Step 4 - Install plugins

In this step, we will guide you how to install Grafana plugins. There are three type of Grafana plugins we need to know:

Panel plugins - These allow new data visualization to be added to Grafana.

Data Source - These are Grafana Data Source plugins.

App - These are bundles of panels, data source, dashboard with new UI.

For plugin installation, Grafana provides a command line tool dubbed 'grafana-cli'. Run it to see the instruction.

grafana-cli

To get a list of all available plugins in the repository, use the following command.

grafana-cli plugins list-remote

To install a plugin, use 'plugins install' option as shown below.

grafana-cli plugins install grafana-clock-panel

After the plugin installed, restart the Grafana service.

systemctl restart grafana-server

To get a list of all installed plugins on your system, use the following command.

grafana-cli plugins ls

And if you want to remove a plugin, use 'plugins remove' option as below.

grafana-cli plugins remove grafana-clock-panel

Conclusion

So, in this tutorial, we are able to install Grafana on Linux servers through both Debian and rpm packages. In the next tutorial, we will try to add the data source. For the record, Grafana supports many data sources including Influxdb, Elasticsearch, Graphite, and Prometheus.

Reference

Muhammad Arul is a freelance system administrator and technical writer. He is working with Linux Environments for more than 5 years, an Open Source enthusiast and highly motivated on Linux installation and troubleshooting. Mostly working with RedHat/CentOS Linux and Ubuntu/Debian, Nginx and Apache web server, Proxmox, Zimbra Administration, and Website Optimization. Currently learning about OpenStack and Container Technology.