How to install Prometheus on CentOS 7

Share on Social Media

Prometheus is a free and open source network monitoring tool. In this article, you will learn how to install Prometheus on CentOS 7. #centlinux #linux #prometheus

What is Prometheus? :

Prometheus is a free and open source software application used for event monitoring and alerting. It collects and records real-time metrics in a time series database and alert the users based on custom defined thresholds. Prometheus is written in Go programming language and distributed under Apache License 2.0.

Prometheus requires multiple exporters that must be installed on the target nodes. The exporter generates and publish the metrics on a relevant port on the target node. The Prometheus monitoring server will pull these metrics and store in a time series database. Following architecture diagram from Prometheus Documentation clarifies the concept and flow of the system.

Prometheus Architecture Diagram

In this guide, we will install Prometheus on CentOS 7 along with node_exporter.

If you want to know more about Prometheus software than you should read Prometheus: Up & Running (PAID LINK) by O’Reilly Media.

Prometheus Features:

Following are the core features of Prometheus.

  • Multi-dimensional data model
  • Write powerful queries with PromQL
  • Grafana integration for great visualization
  • Efficient storage (in memory and disk) of time series data
  • Precise alerts using Alertmanager

Environment Specification:

We have configured a CentOS 7 based Linux virtual machine for this tutorial.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – CentOS 7.7
  • Hostname –
  • IP Address – /24

Configure Prometheus Prerequisites:

Connect with using ssh as root user.

As a best practice, we are creating a Linux user to own Prometheus software and processes.

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

Create required directories for Prometheus software.

# mkdir /etc/prometheus
# mkdir /var/lib/prometheus

Change owner and group of these directories to Prometheus.

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

Install Prometheus on CentOS 7:

You can download Prometheus network monitoring software from their official website or from it’s GitHub repository.

Here, we are downloading latest version of Prometheus with the help of wget Linux command.

# cd /tmp
# wget
--2019-10-30 18:35:53--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 57079650 (54M) [application/octet-stream]
Saving to: âprometheus-2.13.1.linux-amd64.tar.gzâ

100%[======================================>] 57,079,650   240KB/s   in 4m 24s

2019-10-30 18:40:19 (211 KB/s) - âprometheus-2.13.1.linux-amd64.tar.gzâ saved [57079650/57079650]

Extract downloaded zip file to install Prometheus on CentOS 7.

# tar xf prometheus-2.13.1.linux-amd64.tar.gz

Move Prometheus files to /var/lib/prometheus directory.

# mv prometheus-2.13.1.linux-amd64/* /var/lib/prometheus/

Adjust owner and group of /var/lib/prometheus directories.

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

Prometheus zip file also contains a configuration file with default settings. We can use this file to configure our Prometheus server.

With the help of mv Linux command, move Prometheus configuration file to /etc/prometheus directory.

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

Create a soft link of prometheus executable file, so we can execute the prometheus command from CLI.

# ln -s /var/lib/prometheus/prometheus /usr/local/bin/prometheus

To setup autostart of Prometheus at the time of Linux server startup, we need to create a Systemd service for Prometheus network monitoring tool as follows.

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

And add following directives in that file.


--config.file /etc/prometheus/prometheus.yml 
--storage.tsdb.path /var/lib/prometheus/ 


Enable and start Prometheus network service.

# systemctl enable --now prometheus.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/prometheus.service.

Prometheus uses default service port 9090/tcp. We need to allow this port in Linux firewal, so the network traffic can reach at Prometheus service.

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

Open URL using a web browser.

Prometheus Web Interface Console 1

We are now at the Expression Browser web page. Here, we can search for the metrics, for which Prometheus is collecting data.

To see the graph of the data click on Graph.

Prometheus Web Interface Graph 1

Install Node_Exporter on CentOS 7:

Prometheus receives metrics from many sources like machines, databases, applications, etc.

For this purpose, Prometheus requires an Agent (termed as Exporter) to be installed on each node, for which we want to collect metrics.

There are different types of exporters available at Prometheus website. We can download and use one, according to our requirement. But the most common Exporter that we prefer to install on each node to collect machine metrics is the node_exporter.

In this section, we are installing node_exporter on the same CentOS 7 based Prometheus network monitoring server.

Download Node_Exporter from it’s official download page.

# cd /tmp
# wget
--2019-11-01 23:12:21--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8083296 (7.7M) [application/octet-stream]
Saving to: ânode_exporter-0.18.1.linux-amd64.tar.gzâ

100%[======================================>] 8,083,296    188KB/s   in 84s

2019-11-01 23:13:46 (94.3 KB/s) - ânode_exporter-0.18.1.linux-amd64.tar.gzâ saved [8083296/8083296]

Extract downloaded files as follows.

# tar xf node_exporter-0.18.1.linux-amd64.tar.gz

Create a directory for node_exporter software.

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

Move extracted files to /var/lib/prometheus/node_exporter directory.

# mv node_exporter-0.18.1.linux-amd64/* /var/lib/prometheus/node_exporter
# cd

Change ownership of node_exporter directory.

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

Create a systemd service for node_exporter, so it can be started automically during Linux server startup.

# vi /usr/lib/systemd/system/node_exporter.service

Add following lines of code in this file.

Description=Node Exporter



Enable and start node_exporter service.

# systemctl enable --now node_exporter.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/node_exporter.service.

Node Exporter used default service port 9100/tcp. Therefore, we need to allow this service port in Linux firewall.

# firewall-cmd --permanent --add-port=9100/tcp
# firewall-cmd --reload

Add a Node_Exporter Target in Prometheus Server:

We have successfully installed node_exporter, now we have to add it as a target in Prometheus server.

Edit Prometheus configuration file.

# vi /etc/prometheus/prometheus.yml

and add following directives at the end of file.

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

Restart Prometheus service to take changes into effect.

# systemctl restart prometheus.service

Browse URL and search for some node metrics there.

We are searching node_memory_MemAvailable_bytes metric here.

Prometheus Web Interface Console 2

To see the graph of this metric click on Graph button.

Prometheus Web Interface Graph 2

Since, we have recently added this node to Prometheus Server, therefore, there isn’t much time series data available yet. Hence, we have adjusted time to 1m to fill the graph completely.


In this guide, you have learned how to install Prometheus on CentOS 7 along with node_exporter.

Scroll to Top