How To Install Prometheus on Ubuntu 20.04 LTS

Install Prometheus on Ubuntu 20.04

In this tutorial, we will show you how to install Prometheus on Ubuntu 20.04 LTS.  For those of you who didn’t know, Prometheus is an excellent open-source monitoring system which allows us to collect metrics from our applications and stores them in a database, especially a time-series based DB. The biggest advantage of Prometheus is the query language it provides for data processing.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step by step installation Prometheus on Ubuntu 20.04 Focal Fossa. You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian based distribution like Linux Mint.

Install Prometheus on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running these following apt commands in the terminal.

Step 2. Installing Nginx web server.

Nginx is available in the default Ubuntu repositories. To install it run the following command:

Once the installation is completed, run the commands to enable Nginx to automatically startup when your server starts:

Step 3. Create Prometheus Users.

We have to create the user and group called prometheus and also the directory called as Prometheus:

Step 4. Installing Prometheus on Ubuntu 20.04.

Download the latest stable release of Prometheus using the wget command:

Once file extraction was completed, then move the prometheus and promtool binaries under the extracted Prometheus archive folder to/usr/local/bindirectory:

Step 5. Configure Prometheus.

We will create the configuration file named prometheus.yml in the /etc/prometheus directory:

The content of prometheus.yml is as follow:

Step 6. Create a Prometheus Systemd Service.

Now, we will create a file for the systemd service:

Add the following file:

Then, change the ownership of these directories to Prometheus user and group:

Once you are done with the above configurations, reload systemd using the following command:

Step 7. Configure Firewall.

Meanwhile, you need to make sure that your firewall is configured to allow traffic on HTTP (80), HTTPS (443) and 9090 ports. Nginx registers itself as a service with ufw :

Step 8. Accessing Prometheus Web Interface.

Prometheus will be available on HTTP port 9090 by default. Open your favourite browser and navigate to http://your-domain.com:9090 or http://server-ip-addreess:9090 and complete the required steps to finish the installation.

Install Prometheus on Ubuntu 20.04

Congratulations! You have successfully installed Prometheus. Thanks for using this tutorial for installing Prometheus open-source monitoring on your Ubuntu 20.04 LTS (Focal Fossa). For additional help or useful information, we recommend you to check the official Prometheus website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!