Install Prometheus and Node Exporter on CentOS / RHEL 8

Prometheus is a free software application used for event monitoring and alerting. It records real-time metrics in a time series database built using a HTTP pull model, with flexible queries and real-time alerting. The project is written in Go and licensed under the Apache 2 License, with source code available on GitHub, and is a graduated project of the Cloud Native Computing Foundation, along with Kubernetes and Envoy.

Update System

Update your Linux operating system with

# dnf update -y

Prometheus currently does not includes an official SELinux policy. So you have to disable SELinux or switch it into permissive mode.

# sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux
# setenforce permissive

Create Prometheus User and Directories

To own Prometheus software and processes.

# useradd --no-create-home -s /bin/false prometheus

Create required Prometheus directories and edit the ownership.

# mkdir /etc/prometheus
# mkdir /var/lib/prometheus
# chown prometheus:prometheus /var/lib/prometheus
# chown prometheus:prometheus /etc/prometheus

Install Prometheus

You can download it from Prometheus official website.

Download Prometheus tarball with wget command as following below.

[root@unixcop ~]#  wget -P /tmp
--2021-09-09 11:02:11--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: [following]
--2021-09-09 11:02:13--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 73175122 (70M) [application/octet-stream]
Saving to: '/tmp/prometheus-2.29.2.linux-amd64.tar.gz'

prometheus-2.29.2.linux-amd64.tar.gz  100%[=======================================================================>]  69.79M   169KB/s    in 6m 30s  

2021-09-09 11:08:43 (183 KB/s) - '/tmp/prometheus-2.29.2.linux-amd64.tar.gz' saved [73175122/73175122]

[root@unixcop ~]#

Then extract the downloaded Prometheus tarball into the /var/lib/prometheus as shown.

tar -xf /tmp/prometheus-2.29.2.linux-amd64.tar.gz -C /var/lib/prometheus/ --strip-components=1

Give the ownership of the extracted files to Prometheus user with:

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

Move Prometheus configuration file to /etc/prometheus with:

mv /var/lib/prometheus/prometheus.yml /etc/prometheus/

Also check the configurations of prometheus.yml file as shown below:

[root@unixcop ~]# grep -v '#' /etc/prometheus/prometheus.yml

    - static_configs:
        - targets:


  - job_name: "prometheus"

      - targets: ["localhost:9090"]
[root@unixcop ~]#

Also create symbolic links for Prometheus to make them executable from any path.

# cp -s /var/lib/prometheus/promtool /usr/bin
# cp -s /var/lib/prometheus/prometheus /usr/bin

Create Systemd Service Unit for Prometheus

You are required to create systemd service unit for enabling an Autostart of Prometheus.

Follow these steps:

# vim /usr/lib/systemd/system/prometheus.service

Then add the following.


ExecStart=/usr/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/var/lib/prometheus/consoles \


Then enable and start Prometheus with:

[root@unixcop ~]# systemctl enable --now prometheus.service
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/prometheus.service.
[root@unixcop ~]#

Also configure Firewall for Prometheus

The default port 9090/tcp. So it is necessary to allow it to.

[root@unixcop ~]# firewall-cmd --permanent --add-port=9090/tcp
[root@unixcop ~]# firewall-cmd --reload
[root@unixcop ~]#

Open URL http://localhost:9090 in a web browser as shown in below screenshot

Install Node Exporter

Node Exporter is a Prometheus exporter for server level and  level metrics with configurable metric collectors. It helps us in measuring server resources such as disk space, RAM and CPU utilization.

You need to install node_exporter on your Prometheus server .

Firstly, make a directory for Node Exporter as follow:

# mkdir -p /var/lib/prometheus/node_exporter

Download Node_Exporter from Prometheus website.

[root@unixcop ~]# wget -P /tmp
--2021-09-09 11:42:18--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: [following]
--2021-09-09 11:42:19--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8898481 (8.5M) [application/octet-stream]
Saving to: '/tmp/node_exporter-1.2.2.linux-amd64.tar.gz'

node_exporter-1.2.2.linux-amd64.tar.g 100%[=======================================================================>]   8.49M   204KB/s    in 42s     

2021-09-09 11:43:02 (207 KB/s) - '/tmp/node_exporter-1.2.2.linux-amd64.tar.gz' saved [8898481/8898481]

[root@unixcop ~]#

Then extract downloaded tarball to /var/lib/prometheus/node_exporter/ with the following command.

# tar xf /tmp/node_exporter-1.2.2.linux-amd64.tar.gz -C /var/lib/prometheus/unixcop_node_exporter/ --strip-components=1

Modify the ownership.

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

Also create a symbolic link for node_exporter with:

[root@unixcop ~]# cp -s /var/lib/prometheus/unixcop_node_exporter/node_exporter /usr/bin/

Enable autostart of node_exporter process, create a systemd service unit.

vim /usr/lib/systemd/system/unixcop_node_exporter.service

Then add the following:

Description=Node Exporter



Enable and start Node Exporter with command below:

[root@unixcop ~]# systemctl enable --now unixcop_node_exporter.service
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/node_exporter.service.
[root@unixcop ~]#

Also configure firewall to allow node_exporter port 9100/tcp.

[root@unixcop ~]# firewall-cmd --permanent --add-port=9100/tcp
[root@unixcop ~]# firewall-cmd --reload
[root@unixcop ~]#

Then edit Prometheus configuration file.

# vi /etc/prometheus/prometheus.yml

And add the unixcop_node_exporter endpoint configuration in this file.

 - job_name: 'unixcop_node_exporter'
    - targets: ['localhost:9100']

Then restart Prometheus.

# systemctl restart prometheus.service

Open your browser then go to prometheus.

Open Status

Then click on Targets .


In this article, we explained how to install Prometheus systems monitoring tool on CentOS / RHEL 8.

Also we illustrated how to install Node Exporter for server level and  level metrics that helps us to measure server resources such as disk space, RAM and CPU utilization.

unixcop Admin


Please enter your comment!
Please enter your name here

Latest articles

You might also likeRELATED

How to Count Number of Files and Sub-directories inside a Directory

Hi guys, In this article we will show you how to count the number of files and sub-directories in a directory using a tree command. Count number...

Find Top 10 IP Addresses Accessing Your Apache Web Server

In this post, you will learn how to Find Top 10 IP Addresses Accessing Your Apache Web Server- The monitoring access to your web server...

How to Install MongoDB in CentOS 8

Introduction MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). MongoDB is a...