Install and Configure Grafana and Prometheus on Windows VPS
This guide provides a detailed setup for installing and configuring Grafana and Prometheus on a Windows VPS running Ubuntu 24.04, Debian 12, CentOS 9 Stream, or AlmaLinux 9. It includes Node Exporter for system metrics, Nginx as a reverse proxy for Grafana, and secure configuration practices. For reliable VPS hosting, explore Netcloud24.
Author: Łukasz Bodziony | Website: Windows VPS
Prerequisites
- Windows VPS with root or sudo access.
- Minimum 2GB RAM, 10GB disk space, and 2 CPU cores.
- SSH client (e.g., PuTTY or
ssh) for remote access. - Basic Linux command-line knowledge.
- Ports required: 9090 (Prometheus), 9100 (Node Exporter), 3000 (Grafana), 80/443 (Nginx).
- Optional: Domain name for Grafana with SSL (recommended).
Why Netcloud24? Netcloud24 offers high-performance VPS solutions with Intel Xeon Gold CPUs, NVMe SSDs, and 24/7 support, perfect for hosting Grafana and Prometheus. Visit Netcloud24 for scalable plans starting at €92.24/month.
Distribution Comparison
| Distribution | Package Manager | Firewall Tool |
|---|---|---|
| Ubuntu 24.04 | apt | ufw |
| Debian 12 | apt | ufw |
| CentOS 9 Stream | dnf | firewalld |
| AlmaLinux 9 | dnf | firewalld |
Part 1: Install and Configure Prometheus
1. Common Steps for All Distributions
- Update system:For Ubuntu/Debian:
sudo apt update && sudo apt upgrade -yFor CentOS/AlmaLinux:
sudo dnf update -y - Create Prometheus user and directories:
sudo useradd --no-create-home --shell /bin/false prometheus sudo mkdir /etc/prometheus /var/lib/prometheus sudo chown prometheus:prometheus /var/lib/prometheus - Download Prometheus (use latest version, e.g., 2.55.0):For x86_64 systems:
cd /tmp wget https://github.com/prometheus/prometheus/releases/download/v2.55.0/prometheus-2.55.0.linux-amd64.tar.gz tar xvf prometheus-2.55.0.linux-amd64.tar.gz cd prometheus-2.55.0.linux-amd64For ARM64, replace with
prometheus-2.55.0.linux-arm64.tar.gz. - Move binaries and configs:
sudo mv prometheus promtool /usr/local/bin/ sudo mv consoles console_libraries prometheus.yml /etc/prometheus/ sudo chown -R prometheus:prometheus /etc/prometheus sudo chmod -R 775 /etc/prometheus - Configure Prometheus:Edit
/etc/prometheus/prometheus.yml:global: scrape_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100'] - Create systemd service:
sudo nano /etc/systemd/system/prometheus.serviceAdd:
[Unit] Description=Prometheus Monitoring Wants=network-online.target After=network-online.target [Service] User=prometheus Group=prometheus Type=simple ExecStart=/usr/local/bin/prometheus \ --config.file=/etc/prometheus/prometheus.yml \ --storage.tsdb.path=/var/lib/prometheus/ \ --web.console.templates=/etc/prometheus/consoles \ --web.console.libraries=/etc/prometheus/console_libraries [Install] WantedBy=multi-user.target - Start and enable Prometheus:
sudo systemctl daemon-reload sudo systemctl start prometheus sudo systemctl enable prometheus - Verify Prometheus:Access
http://your-vps-ip:9090in a browser (temporary firewall rule required).
Part 2: Install and Configure Node Exporter
1. Common Steps for All Distributions
- Create Node Exporter user:
sudo useradd --no-create-home --shell /bin/false node_exporter - Download Node Exporter (e.g., version 1.8.2):For x86_64 systems:
cd /tmp wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz tar xvf node_exporter-1.8.2.linux-amd64.tar.gz cd node_exporter-1.8.2.linux-amd64For ARM64, replace with
node_exporter-1.8.2.linux-arm64.tar.gz. - Move binary:
sudo mv node_exporter /usr/local/bin/ sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter - Create systemd service:
sudo nano /etc/systemd/system/node_exporter.serviceAdd:
[Unit] Description=Node Exporter Wants=network-online.target After=network-online.target [Service] User=node_exporter Group=node_exporter Type=simple ExecStart=/usr/local/bin/node_exporter [Install] WantedBy=multi-user.target - Start and enable Node Exporter:
sudo systemctl daemon-reload sudo systemctl start node_exporter sudo systemctl enable node_exporter - Verify Node Exporter:Access
http://your-vps-ip:9100/metricsto confirm metrics are available.
Part 3: Install and Configure Grafana
1. Ubuntu 24.04
- Add Grafana repository:
sudo apt-get install -y apt-transport-https software-properties-common wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list sudo apt update - Install Grafana:
sudo apt install grafana -y - Start and enable Grafana:
sudo systemctl start grafana-server sudo systemctl enable grafana-server - Verify Grafana:Access
http://your-vps-ip:3000(default login: admin/admin).
2. Debian 12
Follow Ubuntu 24.04 steps for Grafana installation and configuration.
3. CentOS 9 Stream / AlmaLinux 9
- Add Grafana repository:
sudo nano /etc/yum.repos.d/grafana.repoAdd:
[grafana] name=grafana baseurl=https://packages.grafana.com/oss/rpm repo_gpgcheck=1 gpgcheck=1 gpgkey=https://packages.grafana.com/gpg.key enabled=1 - Install Grafana:
sudo dnf install grafana -y - Follow steps 3–4 from Ubuntu 24.04.
Part 4: Configure Nginx as Reverse Proxy for Grafana
1. Install Nginx
For Ubuntu/Debian:
sudo apt install nginx -y
For CentOS/AlmaLinux:
sudo dnf install nginx -y
2. Configure Nginx
- Create Nginx configuration:
sudo nano /etc/nginx/sites-available/grafanaAdd (replace
your-domain.comwith your domain or VPS IP):server { listen 80; server_name your-domain.com; location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } - Enable configuration:
sudo ln -s /etc/nginx/sites-available/grafana /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx - Install SSL (recommended):Use Certbot for Let’s Encrypt:
For Ubuntu/Debian:
sudo apt install certbot python3-certbot-nginx -y sudo certbot --nginx -d your-domain.comFor CentOS/AlmaLinux:
sudo dnf install certbot python3-certbot-nginx -y sudo certbot --nginx -d your-domain.com
Part 5: Configure Grafana with Prometheus Data Source
- Log in to Grafana:Access
https://your-domain.comorhttp://your-vps-ip:3000. Default credentials: admin/admin (change password immediately). - Add Prometheus data source:Go to
Configuration > Data Sources > Add data source, select Prometheus, set URL tohttp://localhost:9090, and save. - Create dashboard:Go to
Create > Dashboard, add panels, and use Node Exporter metrics (e.g., CPU usage, memory, disk I/O). Import dashboard ID 1860 for a pre-built Node Exporter dashboard.
Part 6: Configure Firewall
1. Ubuntu 24.04 / Debian 12
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
Note: Avoid opening ports 9090/9100/3000; use Nginx and SSH tunneling for secure access.
2. CentOS 9 Stream / AlmaLinux 9
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --reload
Note: Keep ports 9090/9100/3000 closed; rely on Nginx and SSH tunneling.
Netcloud24 Hosting Solutions
| Plan | Price (Monthly) | vCPU | RAM | SSD | RDS CALs |
|---|---|---|---|---|---|
| RDS X1 | €92.24 | 4 | 8 GB | 100 GiB NVMe | 5 |
| RDS X2 | €179.57 | 8 | 16 GB | 200 GiB NVMe | 5 |
| RDS X3 | €275.52 | 8 | 32 GB | 400 GiB NVMe | 10 |
| RDS X4 | €405.89 | 8 | 64 GB | 1 TB NVMe | 25 |
Netcloud24 Benefits: Host your monitoring stack with Netcloud24’s high-performance VPS, featuring NVMe SSDs, Intel Xeon Gold CPUs, automated backups, VPN support, and 24/7 technical support. Compliant with GDPR and KRI standards. Visit Netcloud24 for plans starting at €92.24/month.
Troubleshooting
- Prometheus not running: Check logs with
journalctl -u prometheus. Verifyprometheus.ymlsyntax. - Node Exporter no metrics: Ensure
node_exporterservice is running (systemctl status node_exporter). - Grafana inaccessible: Confirm Nginx configuration and firewall settings. Check
systemctl status grafana-server. - Contact support: Reach out to Netcloud24 for assistance.
Security Recommendations
- Use strong passwords for Grafana admin account.
- Enable SSL via Let’s Encrypt for Grafana access.
- Restrict firewall to ports 80/443 and SSH (22); use SSH tunneling for local access to Prometheus/Node Exporter.
- Regularly update Prometheus, Node Exporter, and Grafana.
- Enable Netcloud24’s VPN and firewall for additional security.