Share your love
Set up Prometheus Server on AlmaLinux 9: Best Monitoring Service
This guide intends to teach you how 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.
Now follow the steps below on the Orcacore website to install and access the Prometheus server URL dashboard.
Table of Contents
Steps To Set up Prometheus Server on AlmaLinux 9
To install and access the Prometheus server URL, 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.
1. Install Prometheus on AlmaLinux 9
At this point, you can follow the steps below to install and access the Prometheus server URL.
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 https://api.github.com/repos/prometheus/prometheus/releases/latest | 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
2. 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:
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=prometheus
Group=prometheus
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=0.0.0.0:9090 \
--web.external-url=
SyslogIdentifier=prometheus
Restart=always
[Install]
WantedBy=multi-user.target
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
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 URL
Now you can confirm that you can connect to port 9090 by accessing the Prometheus server IP address / DNS name in your web browser.
http://server-ip-or-domain-name:9090
That’s it, you are done.
Conclusion
Prometheus server is a strong and flexible tool for monitoring modern systems. It collects data in real-time, lets you ask detailed questions about that data, and sends alerts when something goes wrong. This makes it a key tool for keeping systems running smoothly. At this point, you have learned to Set up Prometheus Server on AlmaLinux 9.
Hope you enjoy it. You may also interested in these articles:
Install Grafana on AlmaLinux 9
Install ionCube Loader on AlmaLinux 9