Monitoring and Alerting for VPS: Setup Grafana + Prometheus in 30 Minutes
Introduction to VPS Monitoring
In today's digital landscape, maintaining optimal server performance is not just a technical requirement—it is a business imperative. Virtual Private Servers (VPS) power countless applications, websites, and services that organizations depend on daily. Without proper monitoring and alerting mechanisms, infrastructure issues can escalate from minor inconveniences to critical business disruptions before teams even become aware of them.
This guide demonstrates how to implement a robust monitoring solution using Grafana and Prometheus, two industry-leading open-source tools that together provide comprehensive visibility into your VPS infrastructure. Whether you manage a single server or a fleet of instances, this 30-minute setup will transform your operational capabilities.
Why Grafana and Prometheus?
Before diving into implementation, it is essential to understand why this particular technology stack has become the de facto standard for modern infrastructure monitoring.
Prometheus: The Metrics Collection Engine
Prometheus is a time-series database and monitoring system originally developed at SoundCloud. It excels at collecting and storing metrics with the following advantages:
- Pull-based architecture: Prometheus scrapes metrics from configured targets at specified intervals, providing centralized control over data collection
- Powerful query language: PromQL enables sophisticated metric analysis and aggregation
- Service discovery: Automatic detection of monitoring targets in dynamic environments
- Reliability: Designed to remain operational even when other infrastructure components fail
- Dimensional data model: Metrics are identified by name and key-value pairs, enabling flexible querying
Grafana: The Visualization Layer
Grafana transforms raw metrics into actionable insights through intuitive dashboards and visualizations. Key benefits include:
- Multi-source support: Connect to Prometheus, InfluxDB, Elasticsearch, and dozens of other data sources
- Customizable dashboards: Create tailored views for different teams and use cases
- Advanced alerting: Configure sophisticated alert rules with multiple notification channels
- Template variables: Build dynamic dashboards that adapt to different servers or environments
- Community resources: Access thousands of pre-built dashboards for common monitoring scenarios
Prerequisites and System Requirements
Before beginning the installation process, ensure your environment meets the following requirements:
- A VPS running Ubuntu 20.04 LTS or later (other Linux distributions work with minor modifications)
- Minimum 2GB RAM and 2 CPU cores (4GB RAM recommended for production environments)
- Root or sudo access to the server
- Basic familiarity with Linux command-line operations
- Firewall configured to allow necessary ports (3000 for Grafana, 9090 for Prometheus, 9100 for Node Exporter)
Step 1: Installing Prometheus (10 minutes)
Prometheus serves as the foundation of your monitoring infrastructure, collecting and storing time-series data from various exporters.
Download and Install Prometheus
Begin by creating a dedicated system user for Prometheus to enhance security:
sudo useradd --no-create-home --shell /bin/false prometheus
Download the latest Prometheus release and extract it to the appropriate directories:
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
tar -xvf prometheus-2.45.0.linux-amd64.tar.gz
sudo cp prometheus-2.45.0.linux-amd64/prometheus /usr/local/bin/
sudo cp prometheus-2.45.0.linux-amd64/promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
Configure Prometheus
Create the necessary directories and configuration files:
sudo mkdir /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
Create a basic Prometheus configuration file at /etc/prometheus/prometheus.yml with monitoring targets for your VPS. This configuration defines scrape intervals, targets, and basic alerting rules.
Create Systemd Service
Configure Prometheus to run as a system service for automatic startup and management. Create a service file at /etc/systemd/system/prometheus.service that defines how the Prometheus process should be managed, including restart policies and resource limits.
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus
Verify Prometheus is running by accessing http://your-vps-ip:9090 in your web browser.
Step 2: Installing Node Exporter (5 minutes)
Node Exporter collects hardware and operating system metrics from your VPS, providing essential data about CPU usage, memory consumption, disk I/O, network statistics, and more.
Download and install Node Exporter following a similar process to Prometheus installation. Create a dedicated user, extract the binary to /usr/local/bin/, and configure it as a systemd service.
Once running, Node Exporter exposes metrics on port 9100. Update your Prometheus configuration to scrape these metrics by adding Node Exporter as a target in the prometheus.yml file.
Step 3: Installing Grafana (10 minutes)
Grafana provides the visualization layer that transforms Prometheus metrics into comprehensible dashboards and actionable alerts.
Install Grafana
Add the Grafana repository and install the package:
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 and enable the Grafana service:
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
Initial Configuration
Access Grafana at http://your-vps-ip:3000 using the default credentials (admin/admin). You will be prompted to change the password immediately—choose a strong password for production environments.
Step 4: Connecting Grafana to Prometheus (3 minutes)
Establish the connection between your visualization layer and data source:
- Navigate to Configuration → Data Sources in the Grafana interface
- Click Add data source and select Prometheus
- Enter your Prometheus URL:
http://localhost:9090 - Click Save & Test to verify the connection
A successful connection confirms that Grafana can query metrics from Prometheus.
Step 5: Creating Your First Dashboard (5 minutes)
Transform raw metrics into visual insights by creating a comprehensive monitoring dashboard.
Import Pre-built Dashboard
The fastest approach is importing a community dashboard designed for Node Exporter metrics:
- Click the + icon and select Import
- Enter dashboard ID 1860 (Node Exporter Full)
- Select your Prometheus data source
- Click Import
This dashboard immediately provides visibility into CPU usage, memory consumption, disk I/O, network traffic, and system load.
Customize Your Dashboard
Tailor the dashboard to your specific requirements by adding custom panels, adjusting time ranges, and organizing visualizations into logical groups. Consider creating separate dashboards for different aspects of your infrastructure: system resources, application metrics, and business KPIs.
Step 6: Configuring Alerts (5 minutes)
Proactive alerting ensures you are notified of issues before they impact users or business operations.
Define Alert Rules
Create alert rules based on critical thresholds:
- High CPU usage: Alert when CPU exceeds 80% for 5 minutes
- Memory pressure: Notify when available memory drops below 10%
- Disk space: Warn when disk usage exceeds 85%
- Service availability: Alert immediately when critical services become unreachable
Configure Notification Channels
Grafana supports multiple notification channels including email, Slack, PagerDuty, Microsoft Teams, and webhooks. Configure at least two channels for redundancy—for example, email for non-critical alerts and Slack for urgent notifications.
Navigate to Alerting → Notification channels to configure your preferred communication methods. Test each channel to ensure notifications are delivered successfully.
Best Practices for Production Environments
Elevate your monitoring implementation with these professional recommendations:
- Implement retention policies: Configure appropriate data retention periods based on compliance requirements and storage capacity
- Secure your installation: Enable HTTPS, implement authentication, and restrict network access using firewalls
- Create alert hierarchies: Distinguish between informational, warning, and critical alerts to prevent alert fatigue
- Document your dashboards: Add descriptions and annotations to help team members understand metrics and thresholds
- Regular backups: Back up Grafana dashboards and Prometheus configuration files
- Monitor the monitors: Ensure Prometheus and Grafana themselves are monitored for availability and performance
- Capacity planning: Track metric growth and storage consumption to plan infrastructure scaling
Conclusion
In just 30 minutes, you have implemented a professional-grade monitoring solution that provides comprehensive visibility into your VPS infrastructure. Grafana and Prometheus together deliver the observability foundation necessary for maintaining reliable, high-performance systems.
This monitoring stack scales from single-server deployments to complex multi-cloud environments, making it an investment that grows with your infrastructure. The combination of real-time metrics, historical analysis, and proactive alerting transforms reactive firefighting into proactive system management.
As you become more familiar with these tools, explore advanced features such as recording rules for query optimization, federation for multi-datacenter monitoring, and custom exporters for application-specific metrics. The monitoring journey does not end with installation—continuous refinement of dashboards, alerts, and collection strategies ensures your monitoring system evolves alongside your infrastructure needs.
