SRE in Practice | Day 13: Linux Server Health Monitoring and Predictive Alerts with Prometheus, Node Exporter, Grafana, and Alertmanager
A beginner-friendly, hands-on DevOps/SRE project - Build a Linux monitoring lab that collects server metrics, visualizes

✍️ Translate this blog into Hindi, Tamil or Telugu
1. Introduction
Production Linux servers can become slow or unavailable because of high CPU utilization, memory pressure, low disk space, or service failures. Commands such as top, free, and df are useful for troubleshooting, but teams also need continuous monitoring, historical trends, dashboards, and alerts.
In this project, we will build a monitoring stack using:
- Node Exporter: collects operating-system and hardware metrics
from Linux.
🛍️✨ From the author · ByteStoreCareer gap analysis and Mentoring - Basic PlanβΉ299View offer →- Prometheus: scrapes and stores time-series metrics.
- Grafana: visualizes metrics in dashboards.
- Alertmanager: groups and routes alerts generated by Prometheus.
2. Architecture
Linux Host
|
v
Node Exporter (9100)
|
| Metrics
v
Prometheus (9090) ------> Alertmanager (9093)
|
v
Grafana (3000)- Node Exporter reads host statistics.
- Prometheus periodically scrapes Node Exporter.
- Prometheus stores the metrics.
- Grafana queries Prometheus and displays dashboards.
- Prometheus evaluates alert rules and sends firing alerts to alertmanager.
- Alertmanager groups and routes alerts to configured receivers.
3. Prerequisites
This guide uses Docker Compose to run the monitoring components on one Ubuntu VM. It is a learning lab, not a production security blueprint.

4. Install Docker
Follow the official Docker Ubuntu installation guide: <https://docs.docker.com/engine/install/ubuntu/>
Verify the installation:
docker --version
docker compose versionIf your user is not configured for Docker access, use sudo docker for the commands below.
5. Create the project structure
linux-monitoring-project/
βββ docker-compose.yml
βββ prometheus/
β βββ prometheus.yml
β βββ alert-rules.yml
βββ alertmanager/
β βββ alertmanager.yml
βββ grafana/
βββ provisioning/
β βββ datasources/datasource.yml
β βββ dashboards/dashboard.yml
βββ dashboards/linux-health.jsonCreate the directories:
mkdir -p linux-monitoring-project/{prometheus,alertmanager}
mkdir -p linux-monitoring-project/grafana/provisioning/{datasources,dashboards}
mkdir -p linux-monitoring-project/grafana/dashboards
cd linux-monitoring-project6. Configure Docker Compose
Create docker-compose.yml:
services:
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
command:
- --path.rootfs=/host
pid: host
volumes:
- /:/host:ro,rslave
expose:
- "9100"
networks:
- monitoring
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./prometheus/alert-rules.yml:/etc/prometheus/alert-rules.yml:ro
- prometheus-data:/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
ports:
- "127.0.0.1:9090:9090"
depends_on:
- node-exporter
- alertmanager
networks:
- monitoring
alertmanager:
image: prom/alertmanager:latest
container_name: alertmanager
restart: unless-stopped
volumes:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
command:
- --config.file=/etc/alertmanager/alertmanager.yml
ports:
- "127.0.0.1:9093:9093"
networks:
- monitoring
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: unless-stopped
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: CHANGE_THIS_LAB_PASSWORD
volumes:
- grafana-data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
ports:
- "127.0.0.1:3000:3000"
depends_on:
- prometheus
networks:
- monitoring
networks:
monitoring:
volumes:
prometheus-data:
grafana-data:Replace CHANGE_THIS_LAB_PASSWORD with a unique lab password before starting. Do not commit passwords or secrets to a public repository. latest tags are convenient for a short lab; pin tested versions for repeatable or production deployments.
The web ports are bound to localhost on the VM. Use an SSH tunnel or a properly secured access layer to reach them from your workstation.
7. Configure Prometheus
Create prometheus/prometheus.yml:
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- /etc/prometheus/alert-rules.yml
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager:9093
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ["prometheus:9090"]
- job_name: linux-node
static_configs:
- targets: ["node-exporter:9100"]scrape_intervalcontrols how often Prometheus collects metrics.evaluation_intervalcontrols how often alert rules are evaluated.rule_filesidentifies the alert-rule file.node-exporter:9100uses the Docker Compose service name on the
internal network.
8. Create alert rules
Create prometheus/alert-rules.yml:
groups:
- name: linux-server-alerts
rules:
- alert: LinuxServerDown
expr: up{job="linux-node"} == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Linux server is unreachable"
description: "Prometheus cannot scrape the Node Exporter target."
- alert: HighCPUUsage
expr: 100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80
for: 2m
labels:
severity: warning
annotations:
summary: "High CPU usage detected"
description: "CPU usage has remained above 80% for more than 2 minutes."
- alert: HighMemoryUsage
expr: (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100 > 85
for: 2m
labels:
severity: warning
annotations:
summary: "High memory usage detected"
description: "Memory usage has remained above 85% for more than 2 minutes."
- alert: HighRootFilesystemUsage
expr: (1 - (node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"} / node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay"})) * 100 > 85
for: 2m
labels:
severity: warning
annotations:
summary: "Root filesystem usage is high"
description: "Root filesystem usage has remained above 85% for more than 2 minutes."
- alert: RootFilesystemMayFillWithin24Hours
expr: predict_linear(node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}[1h], 86400) < 0
for: 5m
labels:
severity: warning
annotations:
summary: "Root filesystem may run out of space"
description: "Recent trend suggests available root filesystem space may reach zero within 24 hours."
Important: predict_linear() is a statistical linear extrapolation of recent samples. It is not machine learning and cannot guarantee that a disk will fill. Its accuracy depends on the quality and stability of recent data. Treat it as an early-warning signal, not a certainty.
9. Configure Alertmanager
Create alertmanager/alertmanager.yml:
route:
receiver: lab-inbox
group_by:
- alertname
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receivers:
- name: lab-inboxThis minimal configuration accepts and groups alerts but does not send email, Slack, or other external notifications. Add a configured receiver when you are ready to test notifications. Keep credentials out of source control.
10. Configure Grafana
Create grafana/provisioning/datasources/datasource.yml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: trueCreate grafana/provisioning/dashboards/dashboard.yml:
apiVersion: 1
providers:
- name: Linux Health
orgId: 1
folder: Linux Monitoring
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboardsCreate grafana/dashboards/linux-health.json:
{
"title": "Linux Server Health",
"uid": "linux-health",
"schemaVersion": 39,
"version": 1,
"refresh": "15s",
"time": {"from": "now-1h", "to": "now"},
"panels": [
{
"id": 1,
"title": "CPU Usage (%)",
"type": "timeseries",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [{
"expr": "100 - (avg by (instance) (rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)",
"legendFormat": "{{instance}}"
}],
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}
},
{
"id": 2,
"title": "Memory Usage (%)",
"type": "timeseries",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [{
"expr": "(1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100",
"legendFormat": "{{instance}}"
}],
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}
},
{
"id": 3,
"title": "Root Filesystem Usage (%)",
"type": "timeseries",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [{
"expr": "(1 - (node_filesystem_avail_bytes{mountpoint=\"/\",fstype!~\"tmpfs|overlay\"} / node_filesystem_size_bytes{mountpoint=\"/\",fstype!~\"tmpfs|overlay\"})) * 100",
"legendFormat": "{{instance}}"
}],
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8}
},
{
"id": 4,
"title": "Load Average (1 minute)",
"type": "timeseries",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [{
"expr": "node_load1",
"legendFormat": "{{instance}}"
}],
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 8}
},
{
"id": 5,
"title": "Node Exporter Target Status",
"type": "stat",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [{
"expr": "up{job=\"linux-node\"}",
"legendFormat": "{{instance}}"
}],
"gridPos": {"h": 5, "w": 12, "x": 0, "y": 16}
}
]
}The dashboard uses the provisioned Prometheus data source. If you change its UID, update the dashboard reference too.
11. Validate and start the stack
Run these commands from the project directory:
sudo docker compose config
sudo docker compose up -d
sudo docker compose psCheck logs if a service does not start:
sudo docker compose logs prometheus
sudo docker compose logs node-exporter
sudo docker compose logs grafana
sudo docker compose logs alertmanagerFor a fuller validation workflow, use promtool and amtool from matching Prometheus and Alertmanager releases to check their configuration files.
12. Access the interfaces
From your workstation, create an SSH tunnel to the VM:
ssh -L 3000:127.0.0.1:3000 \
-L 9090:127.0.0.1:9090 \
-L 9093:127.0.0.1:9093 \
username@YOUR_SERVER_IPKeep the SSH session open and visit:
| Service | URL |
|---|---|
| Β Grafana | Β http://localhost:3000Β Β |
| Β Prometheus | Β http://localhost:9090 |
| Β Β Alertmanager | Β http://localhost:9093 |
Log in to Grafana with username admin and the lab password configured in Compose. In Prometheus, open Status β Targets and check that the prometheus and linux-node targets are healthy. In Grafana, open the Linux Monitoring folder and select the dashboard.
13. Useful Node Exporter metrics

These are raw metric values. PromQL functions such as rate() and arithmetic expressions help turn them into rates and percentages.
14. Test the monitoring workflow safely
Test the server availability alert
- Confirm that the
linux-nodetarget is up in Prometheus. - Stop the Node Exporter lab container:
sudo docker compose stop node-exporter- Wait longer than the alert's
for: 1mduration. - Check the alert state in Prometheus and Alertmanager.
- Restore the exporter:
sudo docker compose start node-exporterTest threshold alerts
Temporarily lower one alert threshold in the lab configuration so normal lab activity meets the condition. Observe the alert, then restore the original threshold. Do not deliberately exhaust CPU, memory, or disk resources on a production server.
15. Linux troubleshooting commands

A practical workflow is: identify the alert, inspect the dashboard, investigate the host with Linux commands, determine the cause, apply a controlled fix, and verify that metrics return to a healthy state.
16. Common troubleshooting scenarios
Prometheus target is down - Check sudo docker compose ps. - Review Node Exporter logs. - Confirm the target is node-exporter:9100. - Confirm both containers share the monitoring network.
Grafana dashboard shows no data - Confirm the Prometheus target is healthy. - Confirm the data source URL is http://prometheus:9090. - Check that the dashboard queries match metrics available in Prometheus. - Review Grafana logs for provisioning errors.
An alert does not fire - Inspect the rule state under Prometheus Alerts. - Confirm the metric exists and the PromQL expression returns data. - Allow the configured for duration to elapse. - Check Prometheus logs for rule parsing errors.
Cannot open the web interface - Confirm the SSH tunnel is active. - Check that the container is running. - Remember that the ports are bound to localhost on the VM.
17. Production considerations
This is a single-host learning lab. Before adapting it for production:
- Pin and regularly update tested image versions.
- Protect dashboards and APIs with strong authentication and TLS.
- Restrict access to metrics endpoints; never expose Node Exporter
publicly.
- Configure persistent storage, retention, backups, and capacity
planning.
- Configure and test real notification receivers.
- Monitor multiple hosts and consider service discovery.
- Use labels and alert routing that reflect teams, environments, and
service criticality.
- Tune thresholds to reduce noise and alert fatigue.
- Consider high availability and access controls for the monitoring
platform.
- Store credentials in a secret manager, not in source control.
18. Future enhancements
1.Multiple Linux servers: Install Node Exporter on additional hosts and add their private addresses as Prometheus targets
2.Notifications: Configure an Alertmanager receiver and test delivery end to end.
3.Β Ansible automation: Automate Node Exporter installation and configuration.
4. Capacity planning: Track CPU, memory, and filesystem trends over longer periods.
5.SRE practices: Define service-level indicators (SLIs), service-level objectives (SLOs), and actionable alerts.
6. Runbooks: Document investigation and recovery steps for important alerts.
Monitoring is not just about collecting metrics. It is about turning infrastructure signals into useful operational decisions.
Disclaimer: This article describes a learning environment. Review security, availability, retention, authentication, and notification requirements before adapting the configuration for production.
🛍️ Srilakshmi T's shelf
Courses, cohorts and more from the authorGet Srilakshmi T's next blog by email
One email a week when they publish. Add the weekly Best of ByteBlog too. No spam, unsubscribe with one click.
We email you once to confirm. By subscribing you agree to the privacy policy.
More from Srilakshmi T

SRE in Practice | Day 12: Linux Monitoring and USE
Check CPU, memory, disk, and network the structured way. Eight hands-on labs, each with every command explained in plain words and a guide to reading the result.
#sla
SRE in Practice | Day 7: SLOs and SLAs
Turn measurements into targets. Compare SLI, SLO, and SLA, choose realistic objectives, and build a reusable SLO checker. Five hands-on labs.
#automation
SRE in Practice | Day 4 of 30 Toil and Automation
Reduce repetitive operational work. Measure toil, calculate automation payback, and build safe, idempotent scripts.
#sli
SRE in Practice | Day 6: SLIs: What Users Experience
Define and measure Service Level Indicators from the user's side. Six hands-on labs: log-based SLIs, valid events, combined SLIs, and a synthetic probe.

💬 Comments (0)
Top · NewestSign in to comment