How to Install Grafana Server on Ubuntu 20.04 Open Source Monitoring
What is Grafana
Grafana is a free, open source and multi platform analytics and interactive visualization web application. It allows you to query, visualize and alert for the web when connected to supported data sources. Grafana supports many data sources such as Graphite, Prometheus, Influx DB, ElasticSearch, MySQL, PostgreSQL, etc. It also allows you to write plugins from scratch for integration with several different data sources.
It provides a cool and customizable dashboard that helps you track the user behavior, application behavior and frequency of errors popping up in production. The dashboard provides several different individual panels on the grid and visualization options such as geo maps, heat maps, histograms, charts and graphs.
Grafana alternatives to consider are Prometheus, Zabbix or Nagios Core monitoring tools. What we like about Nagios monitoring tool is that it offers alerting for servers, switches, applications and services. Nagios is a host and service as well as network monitoring program written in C.
Grafana Features
Free and open source framework.
Built in support for Graphite, Influx DB, Prometheus, ElasticSearch and CloudWatch.
Either host it on prem or any cloud platform of your choice.
Integrated alerting system to warn you of problems as they occur.
Provides custom plugins to extend Grafana’s functionality.
By default, the Grafana server package is not included in the Ubuntu default repository. So you will need to add the Grafana official repository to APT.
First, you will need to install some required dependencies on your server. You can install all required dependencies by running the following command:
Once the repository is added, update the repository cache with the following command:
apt-get update -y
Please install the Grafana server package by running the following command:
apt-get install grafana -y
Once the Grafana server is installed, you can proceed to the next step.
Manage Grafana Service
By default, the Grafana service is managed by systemd. You will need to start and enable it so that it will start automatically after the system reboot:
Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /lib/systemd/system/grafana-server.service.
To check the status of the Grafana service, run the following command:
Without Nginx, you will need to access the Grafana server by specifying the port 3000 at the end of the URL. So it is a good idea to install and configure Nginx as a reverse proxy to hide the Grafana port and access it via port 80.
First, install the Nginx web server package using the following command:
apt-get install nginx -y
Once the Nginx package is installed, create an Nginx virtual host configuration file using the following command:
Save and close the file then verify the Nginx configuration with the following command:
nginx -t
If everything is fine, you should see the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Finally, restart the Nginx service to apply the configuration changes:
systemctl restart nginx
Verify the status of the Nginx service with the following command:
systemctl status nginx
You should see the following output:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-15 06:57:16 UTC; 5s ago
Docs: man:nginx(8)
Process: 11473 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 11494 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 11496 (nginx)
Tasks: 3 (limit: 4686)
Memory: 4.1M
CGroup: /system.slice/nginx.service
├─11496 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─11497 nginx: worker process
└─11498 nginx: worker process
Apr 15 06:57:16 ubuntu2004 systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 15 06:57:16 ubuntu2004 systemd[1]: Started A high performance web server and a reverse proxy server.
If the UFW firewall is installed and enabled on your server then you will need to allow ports 22 and 80 through the UFW. You can allow all of them by running the following command:
ufw allow 80/tcp
ufw allow 22/tcp
ufw enable
You can now check the status of the UFW firewall using the following command:
ufw status
You will get the following output:
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
Now, open your web browser and access the Grafana server using the URL http://grafana.exampledomain.com. You should see the Grafana login screen:
Provide default admin username as admin, password as admin, and click on the Login button. Once you are logged in, you will see the password reset screen:
Set your new admin password and click on the Submit button. You should see the Grafana server dashboard on the following screen:
Great job! You have read and followed all the steps to Install Grafana Server on Ubuntu 20.04 Open Source Monitoring.
How to Install Grafana Server on Ubuntu 20.04 Conclusion
In this guide, you learned how to install the Grafana server on Ubuntu 20.04. You also learned how to use Nginx as a reverse proxy to hide the Grafana port. You can now connect the external data source to the Grafana server and start monitoring them from the central place.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
51vote
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.