How to Install Prometheus and Grafana on RHEL 7
Prometheus and Grafana form one of the most popular open-source monitoring stacks available today. Prometheus is a time-series database and scraping engine that collects metrics from instrumented targets, while Grafana provides a rich visualization layer on top of that data. Together they give you real-time dashboards, alerting, and long-term metric storage without the licensing costs of commercial alternatives. This guide walks you through installing both tools on a Red Hat Enterprise Linux 7 server, configuring a systemd service for Prometheus, installing Grafana via its official YUM repository, and wiring everything together with the Node Exporter dashboard.
Prerequisites
- A running RHEL 7 server with a non-root sudo user or direct root access
- At least 2 GB of RAM and 10 GB of free disk space
- Internet access to download binaries and RPMs
wgetandtarinstalled (yum install -y wget tar)- Firewalld or iptables configured — ports 9090 (Prometheus) and 3000 (Grafana) must be reachable
- Node Exporter already running on any target hosts you plan to scrape (optional but recommended)
Step 1: Create the Prometheus System User
Running Prometheus as a dedicated unprivileged user reduces the attack surface if the process is ever compromised. Create the user without a login shell and without a home directory:
useradd --no-create-home --shell /bin/false prometheus
Create the directories Prometheus will use for its configuration and time-series data:
mkdir -p /etc/prometheus /var/lib/prometheus
chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
Step 2: Download and Install the Prometheus Binary
Visit https://prometheus.io/download/ to find the latest stable release. At the time of writing, Prometheus 2.x is the current series. Download the Linux AMD64 tarball:
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.51.2/prometheus-2.51.2.linux-amd64.tar.gz
tar xvf prometheus-2.51.2.linux-amd64.tar.gz
cd prometheus-2.51.2.linux-amd64
Copy the binaries and default console files into place:
cp prometheus /usr/local/bin/
cp promtool /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
cp -r consoles /etc/prometheus/
cp -r console_libraries /etc/prometheus/
chown -R prometheus:prometheus /etc/prometheus/consoles
/etc/prometheus/console_libraries
Step 3: Write the Prometheus Configuration File
Prometheus is controlled through a YAML configuration file. Create a minimal but functional /etc/prometheus/prometheus.yml that scrapes both Prometheus itself and any Node Exporter instances:
cat > /etc/prometheus/prometheus.yml <<'EOF'
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets: []
rule_files: []
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter'
static_configs:
- targets:
- 'localhost:9100'
# Add more hosts here: 'server2.example.com:9100'
EOF
chown prometheus:prometheus /etc/prometheus/prometheus.yml
Validate the configuration file using promtool before starting the service:
promtool check config /etc/prometheus/prometheus.yml
Step 4: Create a systemd Service Unit for Prometheus
A proper systemd unit ensures Prometheus starts automatically at boot, restarts on failure, and logs to the journal. Create the unit file:
cat > /etc/systemd/system/prometheus.service <<'EOF'
[Unit]
Description=Prometheus Monitoring System
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
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
--storage.tsdb.retention.time=15d
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
EOF
Reload systemd, enable the service to start at boot, and start it now:
systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus
systemctl status prometheus
Open the firewall to allow access to port 9090:
firewall-cmd --permanent --add-port=9090/tcp
firewall-cmd --reload
Browse to http://<server-ip>:9090 to confirm the Prometheus UI is accessible. Check the Targets page under Status to verify scrape targets are up.
Step 5: Install Node Exporter (Optional but Recommended)
Node Exporter exposes OS-level metrics such as CPU, memory, disk I/O, and network statistics. Install it on every host you want to monitor:
cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.1/node_exporter-1.8.1.linux-amd64.tar.gz
tar xvf node_exporter-1.8.1.linux-amd64.tar.gz
cp node_exporter-1.8.1.linux-amd64/node_exporter /usr/local/bin/
useradd --no-create-home --shell /bin/false node_exporter
chown node_exporter:node_exporter /usr/local/bin/node_exporter
cat > /etc/systemd/system/node_exporter.service <<'EOF'
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable node_exporter
systemctl start node_exporter
firewall-cmd --permanent --add-port=9100/tcp
firewall-cmd --reload
Step 6: Add the Grafana YUM Repository and Install Grafana
Grafana maintains an official RPM repository. Create the repo file so yum can resolve the package:
cat > /etc/yum.repos.d/grafana.repo <<'EOF'
[grafana]
name=Grafana OSS
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
EOF
Install Grafana and its dependencies:
yum install -y grafana
Enable and start the Grafana server service:
systemctl enable grafana-server
systemctl start grafana-server
systemctl status grafana-server
Open port 3000 in the firewall:
firewall-cmd --permanent --add-port=3000/tcp
firewall-cmd --reload
Step 7: Add the Prometheus Data Source in Grafana
Browse to http://<server-ip>:3000. The default credentials are admin / admin — Grafana will immediately prompt you to change the password.
- Click the gear icon (Configuration) in the left sidebar, then select Data Sources.
- Click Add data source and choose Prometheus.
- Set the URL field to
http://localhost:9090. - Leave all other settings at their defaults and click Save & Test.
- Grafana confirms the data source is reachable with a green Data source is working message.
Step 8: Import the Node Exporter Full Dashboard
The community-maintained Node Exporter Full dashboard (ID 1860) provides pre-built panels for CPU, memory, disk, and network metrics. Import it in seconds:
- Click the + icon in the left sidebar and select Import.
- Enter 1860 in the Grafana.com Dashboard field and click Load.
- Select your Prometheus data source from the dropdown that appears.
- Click Import.
You should now see a comprehensive dashboard displaying live system metrics collected by Node Exporter and stored in Prometheus.
Conclusion
You have successfully deployed a full Prometheus and Grafana monitoring stack on RHEL 7. Prometheus scrapes metrics from your targets on a 15-second interval and retains 15 days of time-series data by default, while Grafana renders those metrics as intuitive, real-time dashboards. From here you can extend the setup by adding Alertmanager for notifications, instrumenting your own applications with Prometheus client libraries, or connecting additional data sources such as MySQL or Elasticsearch exporters. The combination of systemctl service management and the promtool configuration checker gives you a production-grade, maintainable setup that fits naturally into standard RHEL 7 operations.