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:
We have to create the user and group called prometheus and also the directory called as Prometheus:
Download the latest stable release of Prometheus using the
curl-shttps://api.github.com/repos/prometheus/prometheus/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
Once file extraction was completed, then move the prometheus and promtool binaries under the extracted Prometheus archive folder to
We will create the configuration file named prometheus.yml in the
The content of prometheus.yml is as follow:
scrape_interval:15s# Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval:15s# Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# - alertmanager:9093
# - "first_rules.yml"
# - "second_rules.yml"
Hereit's Prometheus itself.
# The job name is added as a label job= to any timeseries scraped from this config.
metrics_path defaults to '/metrics'
scheme defaults to 'http'.
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:
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
Prometheus will be available on HTTP port 9090 by default. Open your favourite browser and navigate to
http://server-ip-addreess:9090 and complete the required steps to finish the installation.
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.