Installing Prometheus 2.22.1 on Ubuntu Server 20.04

Installing Prometheus 2.22.1 on Ubuntu Server 20.04

What is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community.

To download the software we click here, select our Operating System: Linux and Architecture: amd64

Then right click on the file name link and select "Copy link location"

Using wget we paste this link to the terminal.

ubumon@ubusrvmon: /home/ubumon>
$ wget https://github.com/prometheus/prometheus/releases/download/v2.22.1/prometheus-2.22.1.linux-amd64.tar.gz

and it will download the files to our server.

ubumon@ubusrvmon: /home/ubumon>
$ ls -lrt
total 62780
-rw-rw-r-- 1 ubumon ubumon 64285764 Nov  5 15:55 prometheus-2.22.1.linux-amd64.tar.gz

So we unzip and extract the files

ubumon@ubusrvmon: /home/ubumon>
$ tar xfz prometheus-2.22.1.linux-amd64.tar.gz

ubumon@ubusrvmon: /home/ubumon>
$ ls -lrt
total 62784
drwxr-xr-x 4 ubumon ubumon     4096 Nov  5 15:53 prometheus-2.22.1.linux-amd64
-rw-rw-r-- 1 ubumon ubumon 64285764 Nov  5 15:55 prometheus-2.22.1.linux-amd64.tar.gz

And we rename the folder to prometheus

ubumon@ubusrvmon: /home/ubumon>
$ mv prometheus-2.22.1.linux-amd64 prometheus

ubumon@ubusrvmon: /home/ubumon>
$ ls -lrt
total 62784
drwxr-xr-x 4 ubumon ubumon     4096 Nov  5 15:53 prometheus
-rw-rw-r-- 1 ubumon ubumon 64285764 Nov  5 15:55 prometheus-2.22.1.linux-amd64.tar.gz

Then we will have to create a linux service.

sudo vi /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
User=ubumon
Restart=on-failure

#Change this line if Prometheus is somewhere different
ExecStart=/home/ubumon/prometheus/prometheus \
  --config.file=/home/ubumon/prometheus/prometheus.yml \
  --storage.tsdb.path=/home/ubumon/prometheus/data

[Install]
WantedBy=multi-user.target

!wq!

We restart the reload the services

ubumon@ubusrvmon: /home/ubumon>
$ sudo systemctl daemon-reload

We start Prometheus

ubumon@ubusrvmon: /home/ubumon>
$ sudo systemctl start prometheus

We check the status of the service

ubumon@ubusrvmon: /home/ubumon>
$ sudo systemctl status prometheus
? prometheus.service - Prometheus Server
     Loaded: loaded (/etc/systemd/system/prometheus.service; disabled; vendor preset: enabled)
     Active: active (running) since Fri 2020-11-13 12:50:16 UTC; 4s ago
       Docs: https://prometheus.io/docs/introduction/overview/
   Main PID: 19294 (prometheus)
.
.
.ts=2020-11-13T12:50:16.880Z caller=main.go:684 msg="Server is ready to receive web requests."

And we enable it so when we reboot the server the service starts automatically.

$ sudo systemctl enable prometheus
Created symlink /etc/systemd/system/multi-user.target.wants/prometheus.service ? /etc/systemd/system/prometheus.service.

A way to check whether Prometheus is running, is to check the ip/dns address of the server and port 9090

http://ip.of.server:9090 and you will see the following.

ie. http://192.168.X.XX:9090/graph

Want to thank me?

Buy Me A Coffee