Install VictoriaMetrics on VPS - Prometheus Alternative
VictoriaMetrics is a time-series database designed for speed and resource efficiency — consuming 7x less RAM than Prometheus, delivering 20x faster queries, and fully compatible with PromQL. If you already have Grafana dashboards using Prometheus, you can switch to VictoriaMetrics without changing a single dashboard or query. Simply point your data source to VictoriaMetrics instead and everything works seamlessly. This article covers installing VictoriaMetrics on a standard VPS, configuring Node Exporter to collect system metrics, and visualizing everything in Grafana with real-world examples.
Why Choose VictoriaMetrics Over Prometheus?
- Lower Memory Footprint: Prometheus uses 4-8 GB of RAM to store metrics for 1 million time series. VictoriaMetrics uses only 1-2 GB for the same workload.
- Faster Queries: Dashboard queries run 20 times faster because VictoriaMetrics uses compressed indexes and efficient storage format.
- Full PromQL Support: All your existing PromQL queries, Grafana dashboards, and scrape configurations work without modification.
- Disk Space Efficiency: Compression is so effective that disk usage is 3-5x lower than Prometheus for the same metrics volume.
- Simple Setup: Single binary, no external dependencies, and straightforward configuration — ideal for VPS environments.
Install VictoriaMetrics on Your VPS
# Download the latest release
mkdir -p /opt/victoria && cd /opt/victoria
VER=$(curl -s https://api.github.com/repos/VictoriaMetrics/VictoriaMetrics/releases/latest | grep '"tag_name"' | head -1 | cut -d'"' -f4)
echo "Downloading VictoriaMetrics $VER"
wget -q https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/$VER/victoria-metrics-linux-amd64-$VER.tar.gz
# Extract the archive
tar xzf victoria-metrics-linux-amd64-$VER.tar.gz
chmod +x victoria-metrics-prod
# Create storage directory
mkdir -p /var/lib/victoria-metrics
chown -R nobody:nogroup /var/lib/victoria-metrics
# Test run
./victoria-metrics-prod -storagePath=/var/lib/victoria-metrics &
sleep 2
curl http://localhost:8428/api/v1/status/tsdb
# Should return JSON response like {"status":"ok","metrics":0}
kill %1
Create a Systemd Service for VictoriaMetrics
# Create the systemd service file
sudo tee /etc/systemd/system/victoria-metrics.service > /dev/null << 'EOF'
[Unit]
Description=VictoriaMetrics Time Series Database
After=network.target
Wants=network-online.target
[Service]
Type=simple
User=nobody
Group=nogroup
WorkingDirectory=/opt/victoria
ExecStart=/opt/victoria/victoria-metrics-prod \
-storagePath=/var/lib/victoria-metrics \
-httpListenAddr=127.0.0.1:8428 \
-retention=12
Restart=on-failure
RestartSec=5s
# Increase file descriptor limit for high cardinality metrics
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
# Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable victoria-metrics
sudo systemctl start victoria-metrics
# Check status
sudo systemctl status victoria-metrics
Install Node Exporter to Collect VPS Metrics
# Download Node Exporter
cd /opt/victoria
VER=$(curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest | grep '"tag_name"' | head -1 | cut -d'"' -f4 | sed 's/v//')
wget -q https://github.com/prometheus/node_exporter/releases/download/v$VER/node_exporter-$VER.linux-amd64.tar.gz
# Extract and install
tar xzf node_exporter-$VER.linux-amd64.tar.gz
sudo cp node_exporter-$VER.linux-amd64/node_exporter /usr/local/bin/
sudo chmod +x /usr/local/bin/node_exporter
# Create systemd service for Node Exporter
sudo tee /etc/systemd/system/node-exporter.service > /dev/null << 'EOF'
[Unit]
Description=Prometheus Node Exporter
After=network.target
[Service]
Type=simple
User=nobody
Group=nogroup
ExecStart=/usr/local/bin/node_exporter \
--collector.textfile.directory=/var/lib/node_exporter \
--collector.systemd \
--web.listen-address=127.0.0.1:9100
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
EOF
# Enable and start Node Exporter
sudo systemctl daemon-reload
sudo systemctl enable node-exporter
sudo systemctl start node-exporter
Configure VictoriaMetrics to Scrape Node Exporter Metrics
# Create Prometheus configuration file
sudo mkdir -p /etc/victoria-metrics
sudo tee /etc/victoria-metrics/prometheus.yml > /dev/null << 'EOF'
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['127.0.0.1:9100']
labels:
instance: my-vps
env: production
- job_name: 'victoria-metrics'
static_configs:
- targets: ['127.0.0.1:8428']
EOF
# Update the VictoriaMetrics service to use the config
sudo systemctl edit victoria-metrics
# Add this line to the [Service] section:
# ExecStart=/opt/victoria/victoria-metrics-prod \
# -storagePath=/var/lib/victoria-metrics \
# -httpListenAddr=127.0.0.1:8428 \
# -promscrape.config=/etc/victoria-metrics/prometheus.yml
# Or use sed to update it:
sudo sed -i 's|-storagePath|-promscrape.config=/etc/victoria-metrics/prometheus.yml -storagePath|' /etc/systemd/system/victoria-metrics.service
sudo systemctl daemon-reload
sudo systemctl restart victoria-metrics
Set Up Nginx Reverse Proxy for Grafana (If Using Grafana)
# If you have Grafana running on port 3000, create an Nginx proxy
sudo tee /etc/nginx/sites-available/grafana > /dev/null << 'EOF'
server {
listen 80;
server_name grafana.yourdomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name grafana.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/grafana.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/grafana.yourdomain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1: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;
proxy_read_timeout 90s;
}
}
EOF
# Enable the proxy
sudo ln -s /etc/nginx/sites-available/grafana /etc/nginx/sites-enabled/ 2>/dev/null || true
sudo nginx -t && sudo systemctl reload nginx
# Install SSL certificate with Let's Encrypt (if not already done)
sudo certbot --nginx -d grafana.yourdomain.com
Add VictoriaMetrics as a Data Source in Grafana
# Open Grafana at https://grafana.yourdomain.com
# Login: admin / your password
# Add Data Source:
# Home → Connections → Data sources → Add data source
# Search for "Prometheus" (VictoriaMetrics uses Prometheus protocol)
# Configure:
# Name: VictoriaMetrics
# URL: http://127.0.0.1:8428
# Auth: None (localhost)
# Save & Test → You should see "datasource is working"
# Switch existing dashboards to use VictoriaMetrics:
# Open any old Grafana dashboard → Dashboard settings → Edit any panel
# Change the data source from Prometheus to VictoriaMetrics instantly
-retention=12 flag (12 months default). You can reduce this based on disk space — for example, -retention=1 keeps only 1 month of data. Check storage usage from the stats API: http://localhost:8428/api/v1/status/tsdbVerify VictoriaMetrics is Working Correctly
# Check service status
sudo systemctl status victoria-metrics
sudo systemctl status node-exporter
# Test the API endpoint
curl -s http://127.0.0.1:8428/api/v1/status/tsdb | python3 -m json.tool
# View all metric labels that have been scraped
curl -s http://127.0.0.1:8428/api/v1/labels | python3 -m json.tool | head -30
# Query a metric from Node Exporter (wait 15-30 seconds after starting)
curl -s 'http://127.0.0.1:8428/api/v1/query?query=node_cpu_seconds_total' | python3 -m json.tool | head -20
# Check disk usage of storage
du -sh /var/lib/victoria-metrics
# View service logs
journalctl -u victoria-metrics -n 50 --no-pager
netstat -tulpn | grep 9100Troubleshooting Common Issues
Error: "cannot open directory /var/lib/victoria-metrics"
VictoriaMetrics does not have permission to access the storage directory — typically caused by incorrect ownership or permissions.
# Check current permissions
ls -ld /var/lib/victoria-metrics
# Fix ownership to nobody user
sudo chown -R nobody:nogroup /var/lib/victoria-metrics
sudo chmod -R 755 /var/lib/victoria-metrics
# Restart the service
sudo systemctl restart victoria-metrics
Error: "addr already in use" port 8428
Another process is using port 8428, possibly an older VictoriaMetrics instance that wasn't properly stopped.
# Find what's using the port
sudo netstat -tulpn | grep 8428
sudo lsof -i :8428
# Kill any stray VictoriaMetrics processes
sudo pkill -9 victoria-metrics
# Restart the service cleanly
sudo systemctl restart victoria-metrics
VictoriaMetrics Disk Usage Growing Continuously
Excessive metric scraping or a very long retention period can consume disk space rapidly.
# Check how many metrics are being stored
curl -s http://127.0.0.1:8428/api/v1/status/tsdb | python3 -m json.tool | grep "Total series"
# Reduce retention period (e.g., from 12 months to 3 months)
sudo systemctl edit victoria-metrics
# Change -retention=12 to -retention=3
sudo systemctl restart victoria-metrics
# Or reduce scrape frequency in prometheus.yml
sudo nano /etc/victoria-metrics/prometheus.yml
sudo systemctl restart victoria-metrics
Grafana Shows "No data" Despite VictoriaMetrics Having Metrics
Usually caused by incorrect data source URL or Grafana not being able to reach VictoriaMetrics.
# Verify Grafana data source settings:
# Connections → Data sources → VictoriaMetrics
# Must show "datasource is working" after Save & Test
# Verify VictoriaMetrics is accessible locally
curl -s http://127.0.0.1:8428/api/v1/status/tsdb
# If Grafana runs in a Docker container, use the host IP instead of localhost
# Example: http://172.17.0.1:8428 (for Docker bridge network)
Error: "too many samples in memory" or Out of Memory
VictoriaMetrics is consuming too much RAM, often due to high cardinality metrics or excessive retention.
# Check current memory usage
ps aux | grep victoria-metrics
free -h
# Reduce retention period
sudo systemctl edit victoria-metrics
# Change -retention=12 to -retention=1 (keep only 1 month)
sudo systemctl restart victoria-metrics
# Or increase scrape interval to reduce metric samples
sudo nano /etc/victoria-metrics/prometheus.yml
# Change scrape_interval from 15s to 60s
sudo systemctl restart victoria-metrics
Frequently Asked Questions
How do VictoriaMetrics and Prometheus differ?
Both are pull-based metrics databases supporting PromQL, but VictoriaMetrics was engineered for resource efficiency. While Prometheus optimizes for correctness and simplicity, VictoriaMetrics prioritizes performance and low overhead through advanced compression, efficient indexing, and optimized storage. For small VPS instances, VictoriaMetrics is superior because you don't need to budget for additional hardware resources just to store and query metrics.
Can I migrate data from Prometheus to VictoriaMetrics?
Full historical data migration is complex, but you can start collecting new metrics immediately by pointing scrape configs at VictoriaMetrics. Existing Prometheus data remains separate. If you need historical data, you can use Prometheus's remote_write feature to send metrics to VictoriaMetrics in parallel, or export data from Prometheus first then ingest it into VictoriaMetrics using custom tools.
How much resource savings can I expect?
Typical savings are 7x less memory, 3-5x less disk space, and 20x faster query performance. A 2 GB RAM server running Prometheus can handle about 50,000 metrics; with VictoriaMetrics, the same hardware handles 250,000-500,000 metrics. If you need to store millions of metrics without expensive hardware upgrades, VictoriaMetrics becomes a highly cost-effective solution.