Server monitoring helps you keep your infrastructure stable and responsive. Without proper insights, you often notice performance issues only after they have already affected your applications. Prometheus and Grafana work together to give you real-time visibility into your server’s CPU, memory, disk activity, and network performance. This guide explains how to install these tools, connect them, and start using ready-made dashboards and alerts.
Understanding Prometheus and Grafana
Before setting up anything, it helps to understand what each tool does and how they work together.
What Is Prometheus
Prometheus is an open-source monitoring system that collects and stores time-series data from your server. It regularly scrapes metrics such as CPU usage, memory consumption, disk I/O, and network throughput. Because the data is stored over time, you can analyze trends and identify early signs of potential issues.
What Is Grafana
Grafana is a visualization platform that connects to Prometheus and displays those collected metrics using customizable dashboards. Instead of reading raw numerical values, you can view graphs, charts, and gauges that update in real time. This makes it easy to monitor server behavior at a glance and react quickly to abnormalities.
Using Prometheus and Grafana together gives you:
- Real-time performance monitoring
- Historical data analysis
- Customizable alerting
- Early problem detection
- Resource usage optimization
Step 1: Install Prometheus and Node Exporter
To get started, you first install Prometheus, which serves as your monitoring backend:
sudo apt update
sudo apt install prometheus Next, you need Node Exporter. This tool exposes your server’s hardware-level metrics so Prometheus can collect them:
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz tar xvfz node_exporter-1.6.1.linux-amd64.tar.gz cd node_exporter-1.6.1.linux-amd64 ./node_exporter After starting Node Exporter, it provides system metrics on port 9100. You can confirm everything works by opening http://your-server-ip:9100/metrics in your browser.
Step 2: Configure Prometheus to Collect Metrics
Now that Node Exporter is running, Prometheus needs to be told where to scrape the data.
Open the configuration file:
sudo nano /etc/prometheus/prometheus.yml Add a scrape job:
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100'] Save the file, then restart Prometheus:
sudo systemctl restart prometheus
sudo systemctl enable prometheus Prometheus now collects metrics from Node Exporter at regular intervals.
Step 3: Install and Configure Grafana
Next, install Grafana so you can visualize your metrics:
sudo apt-get install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install grafana Start Grafana and enable it at boot:
sudo systemctl start grafana-server
sudo systemctl enable grafana-server In your browser, open:
http://your-server-ip:3000 Log in using the default credentials:
- Username: admin
- Password: admin
Grafana will prompt you to set a new password.
Step 4: Connect Grafana to Prometheus
Once inside Grafana, you connect it to Prometheus:
- Go to Configuration → Data Sources
- Click Add data source
- Select Prometheus
- Set the URL to:
http://localhost:9090 - Click Save & Test
If configured correctly, you’ll see a green “Data source is working” message.
Step 5: Import a Pre-Built Dashboard
To get immediate insights, import an existing dashboard instead of building one manually.
- Go to Dashboards → Import
- Enter dashboard ID 1860 (Node Exporter Full)
- Click Load
- Choose your Prometheus data source
- Click Import
This dashboard provides comprehensive system monitoring including:
- CPU usage across all cores
- Memory utilization
- Disk I/O and storage usage
- Network traffic statistics
- System load averages
Step 6: Set Up Alerting (Optional)
By adding alerting rules, you get notifications when something goes wrong.
You can create alerts directly inside your dashboard:
- Click on a panel
- Select Edit → Alert
- Define a condition, such as CPU > 80%
- Add notification channels like email or webhooks
Common alert thresholds:
- CPU usage above 80%
- Memory usage above 85%
- Disk free space below 10%
- Load average higher than your number of CPU cores
This helps you detect performance problems early.
Understanding Your Key Metrics
Prometheus and Node Exporter provide many useful metrics, but some are especially helpful:
CPU Metrics
cpu_usage_idle– Idle CPU time
cpu_usage_system– System-level CPU usage
cpu_usage_user– User-level CPU usage
Memory Metrics
node_memory_MemTotal_bytes– Total RAM
node_memory_MemAvailable_bytes– Available RAM
node_memory_MemFree_bytes– Free memory
Disk Metrics
node_filesystem_avail_bytes– Available disk space
node_disk_read_bytes_total– Disk reads
node_disk_written_bytes_total– Disk writes
Network Metrics
node_network_receive_bytes_total– Bytes received
node_network_transmit_bytes_total– Bytes sent
Knowing these values helps you understand where performance bottlenecks may occur.
Troubleshooting Common Issues
Prometheus not collecting metrics:
- Verify Node Exporter is running on port 9100
- Check Prometheus configuration syntax
- Ensure firewall allows connections between services
Grafana can’t connect to Prometheus:
- Confirm Prometheus is accessible at
localhost:9090
- Check Grafana logs:
sudo journalctl -u grafana-server
- Verify data source configuration
Missing data in dashboards:
- Allow time for metrics collection (initial data may take a few minutes)
- Check that your time range settings are appropriate
- Verify metric names match your Prometheus setup
Advanced Configuration Options
You can customize your setup with additional features:
Enable extra Node Exporter collectors
./node_exporter --collector.systemd --collector.processes Adjust Prometheus retention settings
Modify prometheus.yml based on your storage capacity.
Optimize Grafana performance
Adjust query timeouts for large datasets.
Add security
Enable authentication and HTTPS for production systems.
Additional Tips
- Performance: Monitor Prometheus itself to ensure it’s not consuming excessive resources
- Backups: Regularly backup your Grafana dashboards and Prometheus configuration
Watch Our YouTube Video on Prometheus and Grafana
If you prefer a visual walk-through, you can watch the connected YouTube video based on this guide. In the tutorial, you’ll see the installation steps, configuration changes, and dashboard import process visually, including the setup of Prometheus metrics and Grafana dashboards for server performance monitoring.
Conclusion
Prometheus and Grafana create a powerful monitoring solution that helps you track server performance in real time, identify bottlenecks early, and plan capacity upgrades. With Node Exporter supplying system metrics to Prometheus, and Grafana offering detailed dashboards and alerts, you get full visibility into your server’s health.
You now have everything set up to monitor performance, troubleshoot issues, and stay ahead of potential problems before they affect your services.