Set up Prometheus Server on AlmaLinux 9

This guide intends to teach you to Set up Prometheus Server on AlmaLinux 9.

Prometheus is an open-source monitoring and alerting toolkit for microservices and containers that provides flexible queries and real-time notifications. Prometheus assists in IT monitoring and makes the department aware of any issues with their application program interfaces (APIs) or other connected applications and services. The software checks for irregular traffic that could be a sign of an attack or compromise. Prometheus metrics can be used to track statistics such as top-selling products, top-reviewed products, and order-to-ship times.

Steps To Set up Prometheus Server on AlmaLinux 9

To install Prometheus, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

Install Prometheus on AlmaLinux 9

At this point, you can follow the steps below to install Prometheus on your server.

Create a Prometheus system group and user

First, you need to update your local package index with the following command:

sudo dnf update -y

Then, use the following commands to create a Prometheus system group and user:

# sudo groupadd --system prometheus
# sudo useradd -s /sbin/nologin --system -g prometheus prometheus

Create data & configs directories for Prometheus

At this point, you need to create a directory for Prometheus to store its data. To do this, you can use the following command:

sudo mkdir /var/lib/prometheus

Now use the command below to create the Prometheus config directories on AlmaLinux 9:

for i in rules rules.d files_sd; do sudo mkdir -p /etc/prometheus/${i}; done

Download Prometheus

Here you need to visit the GitHub Prometheus release page and download the latest binary package under /tmp/prometheus directory with the following curl command:

# sudo mkdir -p /tmp/prometheus 
# sudo cd /tmp/prometheus
# curl -s | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -

When your download is completed, extract it by using the command below:

sudo tar xvf prometheus*.tar.gz

Next, switch to your Prometheus directory:

cd prometheus*/

Move the binary files to /usr/local/bin/ directory:

sudo mv prometheus promtool /usr/local/bin/

Verify your Prometheus installation by checking its version:

prometheus --version
prometheus, version 2.43.0 (branch: HEAD, revision: edfc3bcd025dd6fe296c167a14a216cab1e552ee)
  build user:       root@8a0ee342e523
  build date:       20230321-12:56:07
  go version:       go1.19.7
  platform:         linux/amd64
  tags:             netgo,builtinassets

Configure Prometheus on AlmaLinux 9

At this point, you need to move the Prometheus configuration template to the /etc directory:

sudo mv prometheus.yml /etc/prometheus/prometheus.yml

Also, move consoles and console_libraries to the /etc/prometheus directory:

sudo mv consoles/ console_libraries/ /etc/prometheus/

Then, switch back to your home directory:

cd $HOME

Create a Prometheus systemd unit file

To manage the Prometheus service with systemd, you need to create a systemd unit file for Prometheus:

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

Add the following content to the file:


ExecReload=/bin/kill -HUP \$MAINPID
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus \
  --web.console.templates=/etc/prometheus/consoles \
  --web.console.libraries=/etc/prometheus/console_libraries \
  --web.listen-address= \



When you are done, save and close the file.

Set Correct Directory Permissions

At this point, you need to change the ownership of these directories to Prometheus user and group by using the following commands:

# for i in rules rules.d files_sd; do sudo chown -R prometheus:prometheus /etc/prometheus/${i}; done 
# for i in rules rules.d files_sd; do sudo chmod -R 775 /etc/prometheus/${i}; done 
# sudo chown -R prometheus:prometheus /var/lib/prometheus/

Start and Enable the Prometheus service

Now you can start and enable Prometheus service on AlmaLinux 9 with the following commands:

# sudo systemctl daemon-reload
# sudo systemctl start prometheus
# sudo systemctl enable prometheus

Verify your Prometheus service is active and running on AlmaLinux 9:

sudo systemctl status prometheus
● prometheus.service - Prometheus
     Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor pr>
     Active: active (running) since Thu 2023-04-27 04:19:54 EDT; 23s ago
   Main PID: 64661 (prometheus)
      Tasks: 8 (limit: 23609)
     Memory: 19.7M
        CPU: 156ms
     CGroup: /system.slice/prometheus.service
             └─64661 /usr/local/bin/prometheus --config.file=/etc/prometheus/pr>

Configure Firewall for Prometheus

If your server has a running firewall service, you’ll need to open port 9090. To do this, run the following command:

sudo firewall-cmd --zone=public --permanent --add-port 9090/tcp

Reload the firewall to apply the new rules:

sudo firewall-cmd --reload

Access Prometheus Server

Now you can confirm that you can connect to port 9090 by accessing the Prometheus server IP address / DNS name in your web browser.

Prometheus server almalinux 9

That’s it, you are done.


At this point, you have learned to Set up Prometheus Server on AlmaLinux 9.

Hope you enjoy it. You may be interested in these articles:

Install Grafana on AlmaLinux 9

Install ionCube Loader on AlmaLinux 9

Display Disk Space on AlmaLinux

Set up Docker Compose on AlmaLinux 9

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *

Stay informed and not overwhelmed, subscribe now!