Install Grafana on Ubuntu 20.04
Introduction
Grafana is an open-source, multi-platform active monitoring and data visualization software with detailed analytics displayed on charts and graphs. It offers features such as reusable dynamic dashboards, exploring metrics with ad-hoc queries, creating alert rules for important metrics to continuously evaluate and send notifications in case of changes, and collaboration with team members through built-in sharing, among other features. In addition, it provides the capability for integration with data sources like InfluxDB, Elasticsearch, Graphite, and Prometheus. In this article, you will learn how to install Grafana on Ubuntu 18.04 or 20.04 server.
Prerequisites
- Deploy a fully updated Vultr Ubuntu 18.04 or 20.04 Server.
- Create a non-root user with sudo access.
1. Install Grafana
Update the system packages.
$ sudo apt update
Install required system packages.
$ sudo apt-get install -y gnupg2 curl software-properties-common
Add Grafana GPG key.
$ curl https://packages.grafana.com/gpg.key | sudo apt-key add -
Install the Grafana repository.
$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
Update the system packages.
$ sudo apt update
Install Grafana
$ sudo apt -y install grafana
Start Grafana service.
$ sudo systemctl start grafana-server
Enable Grafana service to start on system boot.
$ sudo systemctl enable grafana-server
Check the service status.
$ sudo systemctl status grafana-server
By default, Grafana is accessible on port 3000. To use Grafana on port 80, you can run a reverse proxy to forward all traffic on port 3000 to port 80. To do this, you can follow the instructions in the next step. Otherwise, use port 3000 to access the Grafana web interface.
2. Install and Configure Nginx Reverse Proxy (Optional)
Install Nginx.
$ sudo apt install nginx -y
Start Nginx service.
$ sudo systemctl start nginx
Enable Nginx service to start on system boot.
$ sudo systemctl enable nginx
Check Nginx service status.
$ sudo systemctl status nginx
Unlink the default configuration file.
$ sudo unlink /etc/nginx/sites-enabled/default
Create a new configuration file.
$ sudo nano /etc/nginx/sites-available/grafana.conf
Add the following code in the new file, save and close the file:
server {
listen 80;
location / {
proxy_pass http://localhost:3000;
}
}
Link and activate the new configuration file.
$ sudo ln -s /etc/nginx/sites-available/grafana.conf /etc/nginx/sites-enabled/grafana.conf
Test the configuration file.
$ sudo service nginx configtest
Restart Nginx service.
$ sudo systemctl restart nginx
3. Access Grafana Dashboard
To access the Grafana Web Interface without reverse proxy, go to your browser and visit http://Server_IP:3000/
. For example:
http://192.0.2.10:3000/
To access the Grafana Web Interface over the reverse proxy, go to your browser and visit http://Server_IP/
. For example:
http://192.0.2.10/
Conclusion
You have installed Grafana on your server. You will get a log-in screen. Use admin as your username and admin as your password. You can now access the Dashboard and configure it to begin managing and analyzing your data.
More Information
To learn more about Grafana, go to the official documentation page.