Prerequisites
Before installing Grafana, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
- Prometheus or another data source (see Article 29)
Step 1: Install Grafana
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
sudo apt 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 update
sudo apt install grafana -y
Step 2: Start and Enable Grafana
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
Step 3: Configure Firewall
sudo ufw allow 3000/tcp
Step 4: Access Grafana Web Interface
Open browser at http://YOUR_VPS_IP:3000.
Login with: admin / admin (you will be prompted to change password).
Step 5: Add a Data Source (Prometheus)
- Click Configuration (gear icon) → Data Sources
- Click Add data source → Select Prometheus
- Set URL to
http://localhost:9090 - Click Save & Test
Step 6: Import a Pre-made Dashboard
The easiest way to get started is to import from Grafana.com:
- Click Dashboards → Import
- Enter Dashboard ID: 1860 (Node Exporter Full)
- Select Prometheus as data source
- Click Import
Other useful dashboard IDs:
- 11179 – Linux Server Metrics
- 11074 – Nginx Metrics
- 7362 – MySQL Overview
Step 7: Create a Custom Dashboard
- Click Create → Dashboard → Add new panel
- In Query field, enter PromQL, e.g.,
node_cpu_seconds_total{mode="user"} - Choose visualization type (Time series, Gauge, Table, etc.)
- Click Apply
- Repeat for CPU, memory, disk, network
- Save dashboard (Ctrl+S)
Step 8: Set Up Alerts in Grafana
Grafana can send alerts to email, Telegram, Slack, etc.
- Create a panel with a query that should be monitored
- Go to Alert tab
- Set conditions (e.g., when value > 85 for 5 minutes)
- Configure notification channel (Email, Webhook)
- Save dashboard
Step 9: Secure Grafana with HTTPS (Optional)
Edit /etc/grafana/grafana.ini:
[server]
protocol = https
cert_file = /etc/ssl/certs/grafana.crt
cert_key = /etc/ssl/private/grafana.key
Restart Grafana.
Step 10: Enable Anonymous Access (For public read-only dashboards)
In /etc/grafana/grafana.ini:
[auth.anonymous]
enabled = true
org_role = Viewer
Restart Grafana.
✅ Grafana is ready. You now have a professional monitoring dashboard for your VPS.