Skip to content

Install Prometheus

Video Lecture

Install Prometheus Install Prometheus

Description

We will set up 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 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 $7 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.

Alternatively, I also have a Hetzner Cloud coupon where you will receive €20 in FREE credits for new registrations.


$50 - 30 Day FREE Credit

€20 FREE credits

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 update
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 installation 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

Troubleshooting

When you have problems with Prometheus, you can use journalctl to check for any clues in the Prometheus logs.

journalctl -u prometheus.service -f

Prometheus 2.31 and Ubuntu 22.04 Notes

The video in the lesson was created using Prometheus 2.15.2 on Ubuntu 20.04.

At the time of writing this updated message, the apt package manager will now install Prometheus 2.31.2 and Prometheus Node Exporter 1.3.1.

To know which versions you have installed, you can type,

prometheus --version
prometheus-node-exporter --version

Ubuntu 22.04 LTS is also now available to use.

There are no considerable differences to be aware of as shown and discussed in the video in case you decide to install Prometheus 2.31.2 on Ubuntu 22.04 LTS.

Comments