Prometheus

Installation guide — Collect metrics data and stores them in a time series database

William Donze
2 min readMay 10, 2024

Introduction

In this article we’ll look at how install Prometheus, a tool to collects metrics data and stores that them in a time series database.

Before you start

In my case, I have a RHEL8 machine at my disposal. If you’re using Ubuntu, it won’t be much different, but you may need to adjust some commands.

Installation & configuration

Add a service user to run Prometheus

useradd -rs /bin/false prometheus

Download the latest LTS version of Prometheus

wget https://github.com/prometheus/prometheus/releases/download/v2.45.3/prometheus-2.45.3.linux-amd64.tar.gz -P /tmp/

Extract the file and move the Prometheus folder to /opt

tar -xzf "/tmp/prometheus-2.45.3.linux-amd64.tar.gz" -C /opt

Apply correct permissions to the directory

chown -R prometheus:prometheus "/opt/prometheus-2.45.3.linux-amd64"

Create a symbolic link to make the directory name cleaner

ln -sfn "/opt/prometheus-2.45.3.linux-amd64" "/opt/prometheus"

Create a directory for Prometheus data

mkdir /var/lib/prometheus

Apply correct permissions to the data directory

chown -R prometheus:prometheus /var/lib/prometheus

Create a Prometheus service

vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus \
--config.file=/opt/prometheus/prometheus.yml \
--storage.tsdb.path=/mnt/s3-data/prometheus-data \
--storage.tsdb.retention.time=1y

[Install]
WantedBy=multi-user.target

Reload systemd service manager configuration files

systemctl daemon-reload

Enable and start the service

systemctl enable --now prometheus

Open port 9090 of the firewall to make Prometheus accessible

firewall-cmd --permanent --add-port=9090/tcp
firewall-cmd –reload

Check the service to see if it’s running correctly

systemctl status prometheus

To check if the interface is working correctly, visit the following address http://<ip-of-the-prometheus-machine>:9090

Result

The web interface is working correctly

--

--