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 Rcs Ubuntu 18.04 or 20.04 Server.
- Create a non-root user with sudo access.
1. Install Grafana
Update the system packages.
$ sudo apt updateInstall required system packages.
$ sudo apt-get install -y gnupg2 curl software-properties-commonAdd 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 updateInstall Grafana
$ sudo apt -y install grafanaStart Grafana service.
$ sudo systemctl start grafana-serverEnable Grafana service to start on system boot.
$ sudo systemctl enable grafana-serverCheck the service status.
$ sudo systemctl status grafana-serverBy 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 -yStart Nginx service.
$ sudo systemctl start nginxEnable Nginx service to start on system boot.
$ sudo systemctl enable nginxCheck Nginx service status.
$ sudo systemctl status nginxUnlink the default configuration file.
$ sudo unlink /etc/nginx/sites-enabled/defaultCreate a new configuration file.
$ sudo nano /etc/nginx/sites-available/grafana.confAdd 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.confTest the configuration file.
$ sudo service nginx configtestRestart Nginx service.
$ sudo systemctl restart nginx3. 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.