Install Prometheus

Video Lecture

Install Prometheus Install Prometheus

Description

We will setup a dedicated Prometheus server.

Before you start, you will need a Linux server. Preferably an unrestricted Ubuntu 20.04 LTS Server with root access, since all the commands demonstrated in this course were executed on Ubuntu 20.04 LTS Server. I can can recommend using Digital Ocean for your Ubuntu 20.04 LTS.

You will get $50 Free Credit for 30 Days so you can install many minimal $5 per month Ubuntu VMs during that 30 days and try them out as you need. Occasionally the offer is extended to $100 for 60 days.

You can use other operating systems, such as Centos, but all commands in the course are prepared for Ubuntu 20, so you will experience some differences in syntax or equivalent commands which you may need to research yourself if I can't help you.

Once you have an Ubuntu 20.04 LTS server ready, you can start.

SSH onto your server, on windows I use Putty as my SSH client.

sudo apt install prometheus

This will have installed 2 services being Prometheus and the Prometheus Node Exporter. You can verify there status using the commands. (Press Ctrl-C to exit the status log)

sudo service prometheus status
sudo service prometheus-node-exporter status

Prometheus should now be running.

You can visit it at http://[your ip address]:9090

The install also created a user called Prometheus. You can see which processes it is running by using the command,

ps -u prometheus

Manually Install Specific Prometheus Version

For manually installing the Prometheus binaries visit the instructions as https://prometheus.io/download/

Download the binary that you want.

For example,

wget https://github.com/prometheus/prometheus/releases/download/v2.21.0/prometheus-2.21.0.linux-amd64.tar.gz

After downloading, and before we run it, we should verify it's ok by checking its SHA256 Checksum.

sha256sum prometheus-2.21.0.linux-amd64.tar.gz

The output for prometheus-2.21.0.linux-amd64.tar.gz should be, f1f2eeabbf7822572dce67565dc96ffaa2dd1897dd1d844562552b11123f151a prometheus-2.21.0.linux-amd64.tar.gz

If all is ok, then we can untar the gz archive.

tar xvfz prometheus-2.21.0.linux-amd64.tar.gz

Now CD into the new folder

cd prometheus-2.21.0.linux-amd64

Copy all files to the /usr/local/bin/ folder

cp -r . /usr/local/bin

Create a new system user called prometheus (if it doesn't already exist)

sudo useradd --system prometheus

Create a file called prometheus.service

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

Add the script and save

[Unit]
Description=Prometheus Service
After=network.target

[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/bin/prometheus --config.file=/usr/local/bin/prometheus.yml

[Install]
WantedBy=multi-user.target

Now start and check the service is running.

sudo service prometheus start
sudo service prometheus status

We can now leave the new Prometheus service running. If you ever need to stop the new Prometheus service, then type

sudo service prometheus stop
sudo service prometheus status

Prometheus should now be running.

You can visit it at http://[your ip address]:9090

You can view which processes the prometheus user is running by using this command

ps -u prometheus