Monitoring Linux Servers with Prometheus, Node Exporter, and Grafana
- Caution
🚀 A hands-on guide to setting up a Prometheus-based monitoring stack. We’ll use two Ubuntu-based VMs: one for Node Exporter, and another for Prometheus + Grafana.
🖥️ Architecture Overview
Section titled “🖥️ Architecture Overview”- VM 1 (
vms-01, IP:192.168.1.7): Node Exporter - VM 2 (
vms-02, IP:192.168.1.8): Prometheus & Grafana
🔧 Step 1 — Install Node Exporter
Section titled “🔧 Step 1 — Install Node Exporter”Node Exporter collects hardware and OS metrics, which are then scraped by Prometheus.
sudo useradd --no-create-home --shell /bin/false node_exporterwget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz -P /mntcd /mnttar -zxvf node_exporter-1.6.1.linux-amd64.tar.gzcp node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/binchown node_exporter:node_exporter /usr/local/bin/node_exporterCreate the systemd service:
[Unit]Description=Node ExporterWants=network-online.targetAfter=network-online.target
[Service]User=node_exporterGroup=node_exporterType=simpleExecStart=/usr/local/bin/node_exporter
[Install]WantedBy=multi-user.targetEnable and start the service:
systemctl daemon-reloadsystemctl start node_exportersystemctl enable node_exporterVerify via browser: http://192.168.1.7:9100/metrics
📦 Step 2 — Install Prometheus
Section titled “📦 Step 2 — Install Prometheus”sudo useradd --no-create-home --shell /usr/sbin/nologin prometheuswget https://github.com/prometheus/prometheus/releases/download/v2.46.0/prometheus-2.46.0.linux-amd64.tar.gz -P /mntcd /mnttar -zxvf prometheus-2.46.0.linux-amd64.tar.gzcp prometheus-2.46.0.linux-amd64/{prometheus,promtool} /usr/local/bin/chown prometheus:prometheus /usr/local/bin/prom*
mkdir /etc/prometheuscp -r prometheus-2.46.0.linux-amd64/{consoles,console_libraries,prometheus.yml} /etc/prometheuschown -R prometheus:prometheus /etc/prometheusEdit /etc/prometheus/prometheus.yml:
scrape_configs: - job_name: "prometheus" static_configs: - targets: ["localhost:9090"]
- job_name: "node_exporter" static_configs: - targets: ["192.168.1.7:9100"]Create the Prometheus service:
[Unit]Description=Prometheus MonitoringWants=network-online.targetAfter=network-online.target
[Service]User=prometheusGroup=prometheusType=simpleExecStart=/usr/local/bin/prometheus --config.file /etc/prometheus/prometheus.yml --storage.tsdb.path /etc/prometheus/data/ --web.console.templates=/etc/prometheus/consoles --web.console.libraries=/etc/prometheus/console_libraries
[Install]WantedBy=multi-user.targetEnable and start Prometheus:
systemctl daemon-reloadsystemctl start prometheussystemctl enable prometheusAccess Prometheus UI: http://192.168.1.8:9090
📈 Step 3 — Install Grafana
Section titled “📈 Step 3 — Install Grafana”apt-get install -y apt-transport-https software-properties-common wgetwget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.keyecho "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.listapt-get update -yapt-get install grafana -y
systemctl start grafana-serversystemctl enable grafana-serverAccess Grafana at http://192.168.1.8:3000:
- Username:
admin - Password:
admin
🧩 Integrate Grafana with Prometheus
Section titled “🧩 Integrate Grafana with Prometheus”- Navigate to
Connections→Data Sources - Select
Prometheus→ URL:http://192.168.1.8:9090 - Click
Save & Test
🧠 Dashboard Setup
Section titled “🧠 Dashboard Setup”Use the community dashboard template:
https://grafana.com/grafana/dashboards/10180
Steps:
- Click
New→Import - Enter Dashboard ID:
10180 - Select Prometheus as the data source →
Import
🎉 Done! You now have a powerful, open-source observability stack running.
If you run into issues during setup, drop a question in the comments.
Or share your own monitoring chaos stories — chances are, we’ve all been there 😄