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.

[email protected]: /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.

[email protected]: /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

[email protected]: /home/ubumon>
$ tar xfz prometheus-2.22.1.linux-amd64.tar.gz

[email protected]: /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

[email protected]: /home/ubumon>
$ mv prometheus-2.22.1.linux-amd64 prometheus

[email protected]: /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

[email protected]: /home/ubumon>
$ sudo systemctl daemon-reload

We start Prometheus

[email protected]: /home/ubumon>
$ sudo systemctl start prometheus

We check the status of the service

[email protected]: /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