Monitoring is a crucial part of DevOps, helping teams detect issues before they become critical. In this guide, we will install Prometheus, Grafana, and Node Exporter using Podman, an alternative to Docker. By the end, you'll have a fully functional monitoring stack with visual dashboards to analyze system metrics.
What Are Prometheus, Grafana, and Node Exporter?
1. Prometheus: The Time-Series Database
Prometheus is an open-source monitoring system that collects and stores metrics as time-series data. It is widely used in DevOps due to its powerful querying language (PromQL) and easy integration with multiple exporters.
📌 Key Features:
- Time-series data storage
- Pull-based metric collection
- Alerting and rule-based evaluations
2. Node Exporter: The System Metrics Collector
Node Exporter is a lightweight agent that runs on a machine to collect system metrics such as CPU usage, memory utilization, disk I/O, and network statistics.
📌 Common Metrics Collected:
- CPU Load:
node_cpu_seconds_total
- Memory Usage:
node_memory_MemAvailable_bytes
- Disk Space:
node_filesystem_avail_bytes
- Network Traffic:
node_network_receive_bytes_total
3. Grafana: The Visualization Tool
Grafana is an open-source tool that helps visualize and analyze time-series data. It allows you to create dashboards with real-time graphs, alerts, and reports.
📌 Why Use Grafana?
- Connects to multiple data sources (Prometheus, MySQL, AWS CloudWatch, etc.)
- Beautiful and interactive dashboards
- Custom alerts and notifications
Step 1: Install and Run Containers
We will use Podman, a rootless container runtime similar to Docker, to set up our monitoring stack.
1.1 Pull and Run a CentOS Container
We'll start by running a CentOS container where we will install Node Exporter.
Verify that the container is running:
1.2 Run Prometheus
Now, let's run Prometheus, which will scrape metrics from Node Exporter.
Check if Prometheus is running properly:
You can now access Prometheus at:
👉 http://localhost:9090/query
To enter the Prometheus container:
Step 2: Install and Run Node Exporter
Log into the CentOS container:
Download and extract Node Exporter:
wget https://github.com/prometheus/node_exporter/releases/download/v1.9.0/node_exporter-1.9.0.linux-386.tar.gz
tar -xvf node_exporter-1.9.0.linux-386.tar.gz
cd node_exporter-1.9.0.linux-386
./node_exporter
Now, you can check the collected metrics at:
👉 http://localhost:9100/metrics
Step 3: Configure Prometheus to Scrape Node Exporter Metrics
Modify the Prometheus configuration file (prometheus.yml
):
Add the following configuration:
global:
scrape_interval: 15s # Collect metrics every 15 seconds
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "centos_node_exporter"
static_configs:
- targets: ["localhost:9100"]
Restart Prometheus:
Check if Prometheus is scraping Node Exporter:
👉 http://localhost:9090/targets
Step 4: Deploy Grafana
Run the Grafana container:
Get the IP address of Prometheus:
Access Grafana at:
👉 http://localhost:3000
📌 Default Login:
- Username:
admin
- Password:
admin
(change it on first login)
Step 5: Add Prometheus as a Data Source in Grafana
- Open Grafana (
http://localhost:3000
). - Go to Configuration > Data Sources.
- Click "Add Data Source", select Prometheus.
- Set the URL as
http://prometheus:9090
. - Click "Save & Test".
Step 6: Import Node Exporter Dashboard
- In Grafana, go to "Create" > "Import".
- Enter the Dashboard ID:
1860
(or search for "Node Exporter Full"). - Select Prometheus as the data source.
- Click "Import".
You should now see a full system monitoring dashboard! 🎉
Step 7: Managing Containers
To stop and remove containers:
Restart Prometheus and Grafana: