top of page
Recent Posts

How to install and configure Prometheus & grafana in Red Hat Enterprise Linux 7

Updated: Oct 3, 2021

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. The Prometheus ecosystem consists of multiple components, many of which are optional:

  • the main Prometheus server which scrapes and stores time series data

  • client libraries for instrumenting application code

  • a push gateway for supporting short-lived jobs

  • special-purpose exporters for services like HAProxy, StatsD, Graphite, etc.

  • an alertmanager to handle alerts

  • various support tools

Grafana is open source visualization and analytics software. It allows you to query, visualize, alert on, and explore your metrics no matter where they are stored. In plain English, it provides you with tools to turn your time-series database (TSDB) data into beautiful graphs and visualizations. Grafana supports querying Prometheus.

The architecture of Prometheus and some of its ecosystem components:

And Prometheus + Grafana could be the complementary services that consider as a tools to build up a monitoring system. Lets start the configuration.

Installing Prometheus Server:

Step:1 To download Prometheus binaries for Linux from

# cd /tmp/ 
# wget 

::::::::::::: CUT SOME OUTPUT :::::::::::::

100%[========================================================================================================>] 65,312,139   287KB/s   in 5m 25s 
2020-07-25 18:16:23 (196 KB/s) - ‘prometheus-2.20.0.linux-amd64.tar.gz’ saved [65312139/65312139]

Step:2 To prepared prerequisite configurations for Prometheus.

# ueradd --no-create-home -s /bin/false prometheus
# mkdir /etc/prometheus
# mkdir /var/lib/prometheus
# chown prometheus:prometheus /etc/prometheus
# chown prometheus:prometheus /var/lib/prometheus

Step:3 To extract downloaded zip file & configure Prometheus.

# tar -zxvf /root/prometheus-2.20.0.linux-amd64.tar.gz 
::::::::::::: CUT SOME OUTPUT :::::::::::::

# mv /var/lib/prometheus/prometheus.yml /etc/prometheus/
# chown -R prometheus:prometheus /var/lib/prometheus

# mv /var/lib/prometheus/prometheus.yml /etc/prometheus/
# ln -s /var/lib/prometheus/prometheus /usr/local/bin/prometheus

Step:4 To create a systemd configuration file for Prometheus.

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

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


Step:5 To start the Prometheus service.

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

Step:6 To open port in firewall, if firewall service is running.

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

Step:7 To verify the Prometheus service, open the URL http://<prometheus_ipaddress>:9090 using a client's browser.

OK, good to go for the next.

Installing Node_Exporter:

Prometheus receives metrics from many sources like machines, databases, applications, etc. But the most common Exporter that we prefer to install on each node to collect machine metrics is the node_exporter. Let's install the Node_Exporter.

Step:1 To download Node_Exporter from Prometheus Download Page.

# cd /tmp
# wget
--2020-07-27 13:19:58-- 

::::::::::::: CUT SOME OUTPUT :::::::::::::

100%[========================================================================================================>] 9,520,728    149KB/s   in 57s    
::::::::::::: CUT SOME OUTPUT :::::::::::::
2020-07-27 13:20:57 (164 KB/s) - ‘node_exporter-1.0.1.linux-amd64.tar.gz’ saved [9520728/9520728]

Step:2 To prepared prerequisite configurations for Node_Exporter.

# ueradd --no-create-home -s /bin/false prometheus
# mkdir -p /var/lib/prometheus/node_exporter

Step:3 To extract downloaded zip file & configure Node_Exporter.

# tar xvf node_exporter-1.0.1.linux-amd64.tar.gz 
# mv node_exporter-1.0.1.linux-amd64/* /var/lib/prometheus/node_exporter
# chown -R prometheus:prometheus /var/lib/prometheus/node_exporter/

Step:4 To create a systemd configuration file for Node_Exporter.

# vi /usr/lib/systemd/system/node_exporter.service
Description=Node Exporter



Step:5 To start the Node_Exporter service.

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

Step:6 To allow node_exporter service port port in firewall, if firewall service is running.

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

Add a Target in Prometheus Server:

Step:1 To edit Prometheus configuration file and add the target.

# vi /etc/prometheus/prometheus.yml

::::::::::::: CUT SOME OUTPUT :::::::::::::
# Here it's Prometheus itself.
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    - targets: ['localhost:9090']

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

Step:2 To restart the Prometheus service to effect changes.

# systemctl restart prometheus
# systemctl status prometheus

Step:3 From the http://<prometheus_ipaddress>:9090/ GUI at client's browser, we can search for the node metrics, e.g. node_memory_MemAvailable_bytes metric. as below

seems like good to go for the next

Installing Grafana:

Step:1 To install required rpm's or packages from the download site.

# wget 
# yum install grafana-7.1.1-1.x86_64.rpm

::::::::::::: CUT SOME OUTPUT :::::::::::::
  grafana.x86_64 0:7.1.1-1                                                                                                                        

Dependency Installed:
  urw-fonts.noarch 0:2.4-16.el7    

Step:2 To configure the smtp connection in grafana service, that can be used for sending emails.

::::::::::::: CUT SOME OUTPUT :::::::::::::
#################################### SMTP / Emailing ##########################
enabled = true
host = localhost:25
user =
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password =
cert_file =
key_file =
skip_verify = false
from_address = admin@grafana.localhost
from_name = Grafana
# EHLO identity in SMTP dialog (defaults to instance_name)
ehlo_identity =
# SMTP startTLS policy (defaults to 'OpportunisticStartTLS')
;startTLS_policy = NoStartTLS
::::::::::::: CUT SOME OUTPUT :::::::::::::

Step:3 To start the grafana service.

# systemctl daemon-reload
# systemctl enable grafana-server.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/grafana-server.service.

# systemctl start grafana-server.service
# systemctl status grafana-server.service

Step:4 To allow grafana service port port in firewall, if firewall service is running.

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

Step:5 To verify the grafana service, open the URL http://<grafana_ipaddress>:3000 using a client's browser.

Note: The default login is username ‘admin’ and password ‘admin’.

wow it' very good to go for the next.

Grafana Configuration:

Step:1 To configure the our Prometheus instance as a data source

Click the Data Sources from the Configuration as below.

Click the Add Data Sources from the Data Sources windows as below.

Click the Select Prometheus from the Add Data Sources windows as below.

Click the save and test the confirmation from the Data Sources/Prometheus windows as below.

Now, we have successfully configure Prometheus in the Grafana.

Step:2 To configure the our Prometheus instance as a data source

Click the Manage from the Dashboard as below.

Click the Import from the Manage as below.

Import the dashboard Node Exporter for Prometheus Dashboard EN v20200628 by the dashboard id 11074, as below.

Step:3 To verify the metrics for my server such as CPU usage or free memory.

Step:4 If we monitor multiple servers, we can switch between them by clicking next to the text ‘JOB’, as below.

Note: Additional servers will appear here if you add them to the Prometheus configuration:

- job_name: 'allinone'


- targets: ['localhost:9100','allinonehost']

Step:4 To set up altering via smtp for the dashboard:

Click the Add Channel from the Alerting as below.

Click the save the confirmation and send test the Notification from the Notification Channel windows, as below.

We can configure the email Notification from the monitoring dashboards that suit for our requirements, if needed.

We now have a fully functional Prometheus ecosystem running on your RHEL 7 server, and we can use Grafana to customize monitoring dashboards that suit our requirements.

1,939 views0 comments


Log In to Connect With Members
View and follow other members, leave comments & more.
bottom of page