How to install and configure Prometheus on CentOS 7


Prometheus is a free open source application used for event monitoring and awareness. Collects and records real-time metrics in a series of data areas. Prometheus is written on Go and distributed under Apache License 2.0.

Prometheus requires many exports to be targeted. The issuer releases and publishes metrics to the appropriate port in the target area. The Prometheus monitoring server will capture these instruments and store them in the timeline. Following the masterpiece from Prometheus, Texts clarifies the concept and flow of the program.

We need two servers: Main-server ( &  Client-server (, Make sure both are accessible

Login to fosnix servers –

Step 1: Update & Disable SELinux

[root@fosnix ~]# yum update -y
[root@fosnix ~]# vim /etc/sysconfig/selinux

Replace “SELINUX=disabled” from “SELINUX=enforcing”

Save & Exit from file

Then, Reboot the System

Step 2 : Download Prometheus package

Run the below command to download the package- 

[root@fosnix ~]# wget

Step 3 : Configure Prometheus

Add a Prometheus user

[root@fosnix ~]# useradd --no-create-home --shell /bin/false prometheus

Create directories & change the owner of them

[root@fosnix ~]# mkdir /etc/prometheus
[root@fosnix ~]# mkdir /var/lib/prometheus
[root@fosnix ~]# chown prometheus:prometheus /etc/prometheus
[root@fosnix ~]# chown prometheus:prometheus /var/lib/prometheus

Now Extract the Prometheus downloaded file & Rename it- 

[root@fosnix ~]# tar -xvzf prometheus-2.8.1.linux-amd64.tar.gz
[root@fosnix ~]# mv prometheus-2.8.1.linux-amd64 prometheuspackage

Copy “prometheus” and “promtool” binary from the “prometheuspackage” directory to “/usr/local/bin” & Change the ownership of them to prometheus user

[root@fosnix ~]# cp prometheuspackage/prometheus /usr/local/bin/
[root@fosnix ~]# cp prometheuspackage/promtool /usr/local/bin/
[root@fosnix ~]# chown prometheus:prometheus /usr/local/bin/prometheus
[root@fosnix ~]# chown prometheus:prometheus /usr/local/bin/promtool

Copy “consoles” and “console_libraries” directories from the “prometheuspackage” to “/etc/prometheus” directory & Change the ownership of them to prometheus user

[root@fosnix ~]# cp -r prometheuspackage/consoles /etc/prometheus
[root@fosnix ~]# cp -r prometheuspackage/console_libraries /etc/prometheus
[root@fosnix ~]# chown -R prometheus:prometheus /etc/prometheus/consoles
[root@fosnix ~]# chown -R prometheus:prometheus /etc/prometheus/console_libraries

Now, to configure the prometheus file you have to create the prometheus.yml file & add the below lines in it

[root@fosnix ~]# vim /etc/prometheus/prometheus.yml
  scrape_interval: 10s

  - job_name: 'prometheus_master'
    scrape_interval: 5s
      - targets: ['localhost:9090']

Save & Exit from file

Change the Ownership of the File

[root@fosnix ~]# chown prometheus:prometheus /etc/prometheus/prometheus.yml

Configure the Prometheus Service File-
Create a file and Copy paste the below lines into it

[root@fosnix ~]# vim /etc/systemd/system/prometheus.service
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \

Save & Exit from file,

Restart the systemd file & Prometheus service

[root@fosnix ~]# systemctl daemon-reload
[root@fosnix ~]# systemctl start prometheus
[root@fosnix ~]# systemctl status prometheus

If your firewall is on, so stop it from the below command- 

[root@fosnix ~]# systemctl stop firewalld

Step 4 : Access Prometheus Web Interface

Open your browser & type the below URL with your SERVER-IP


Step 5 : Monitor Client Server Using Prometheus

Login to Client servers –

You need to download node exporter first by run the command below – 

[root@fosnix ~]# wget

Now, Extract the package

[root@fosnix ~]# tar -xvzf node_exporter-0.17.0.linux-amd64.tar.gz

Next, Create a user for node-exporter & move to /usr/local/bin

[root@fosnix ~]# useradd -rs /bin/false nodeusr
[root@fosnix ~]# mv node_exporter-0.17.0.linux-amd64/node_exporter /usr/local/bin/

Create a file for node-exporter & copy paste the lines below in it

[root@fosnix ~]# vim /etc/systemd/system/node_exporter.service
Description=Node Exporter

Save & Exit from file,

Restart the system daemon,  also start & enable the node exporter

[root@fosnix ~]# systemctl daemon-reload
[root@fosnix ~]# systemctl start node_exporter
[root@fosnix ~]# systemctl enable node_exporter

If your firewall is on, so stop it from the below command- 

Open your browser & type the below URL with your SERVER-IP


Login back to the main-servers –

To configure the node exporter modify the prometheus.yml file

Add the below lines in the file as shown below –

[root@fosnix ~]# vim /etc/prometheus/prometheus.yml
  - job_name: 'node_exporter_centos'
    scrape_interval: 5s
      - targets: ['']

Restart the prometheus service –

[root@fosnix ~]# systemctl restart prometheus

Open your browser & type the below URL with your SERVER-IP


You may also like...

Leave a Reply

Your email address will not be published.