How to Use Prometheus for System Monitoring: A Practical Tutorial
Prometheus is an open-source monitoring system that scrapes metrics from your servers and applications, stores them as time-series data, and fires alerts when thresholds break. Its pull-based model and powerful PromQL query language have made it the default choice for Linux and Kubernetes monitoring.
This tutorial walks you through installing Prometheus, connecting node_exporter, writing your first query, and setting up basic alerts.
1. Install Prometheus and node_exporter
Download the Prometheus binary, extract it, and start it with ./prometheus –config.file=prometheus.yml. Then install node_exporter on every host you want to monitor — it exposes CPU, memory, disk, and network metrics on port 9100.
2. Configure Scraping
Edit prometheus.yml and add a scrape target:
- job_name: “nodes”
- targets: [“localhost:9100”]
- scrape_interval: 15s
Restart Prometheus and verify the target is UP under Status → Targets in the web UI on port 9090.
3. Query Metrics with PromQL
Use expressions like node_cpu_seconds_total or rate(node_cpu_seconds_total[5m]) to inspect CPU trends. Graph results directly in the built-in expression browser.
4. Add Alerting
Define alert rules in a rules.yml file, point Alertmanager at them, and route notifications to email, Slack, or PagerDuty.
Conclusion
Prometheus turns raw system metrics into actionable insight. Start with node_exporter, master a few PromQL queries, then layer on Grafana dashboards and Alertmanager as your infrastructure grows.