Guide to Installing Grafana and Prometheus on Ubuntu VPS

Thanh Hien Content has been moderated
Published date:7/8/2026 Update:21/8/2026 Views:186 Reviews: 4.8/5153reviews
VPTS on

Guide to installing Grafana + Prometheus + Node Exporter on Ubuntu VPS using Docker Compose, helping monitor CPU, RAM, hard drive, network, load average, and server operating status via intuitive dashboards.

Guide vpshosting

During the operation of VPS, servers, websites, or service systems, monitoring server resources is very important. High CPU usage, exhausted RAM, full disk, or abnormal network activity can all cause services to slow down, hang, or be interrupted if not detected early.

Instead of constantly logging into SSH and using commands liketop, htop, free -h hay df -h, we can build a visual monitoring system usingGrafana + Prometheus + Node Exporter.

In this article,VPTSwill guide youinstall Grafana and Prometheus on Ubuntu VPS using Docker Compose from A to Z, including Node Exporter to monitor CPU, RAM, Disk, Network, and other critical VPS metrics.

What is Grafana?

Grafana is an open-source platform used for data analysis, visualization, and monitoring. Grafana helps transform data such as CPU, RAM, disk space, network traffic, metrics, and logs into intuitive, real-time charts and dashboards.

Grafana is commonly combined with Prometheus to build monitoring systems for VPS, servers, applications, and network infrastructure. In this setup, Prometheus collects and stores metrics, while Grafana uses that data to render easy-to-monitor dashboards.

GUIDE TO INSTALLING GRAFANA AND PROMETHEUS

Step 1. Update the system

First, update the package list:

sudo apt update

Step 2. Install Necessary Packages

Installation:

sudo apt install -y ca-certificates curl

Step 3. Add Docker Repository

First, create a directory to store the Docker GPG Key:

sudo install -m 0755 -d /etc/apt/keyrings

Download Docker's official GPG Key:

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc

Grant read permission:

sudo chmod a+r /etc/apt/keyrings/docker.asc

Next, add the Docker Repository:

sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null <<EOF Types: deb URIs: https://download.docker.com/linux/ubuntu Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") Components: stable Architectures: $(dpkg --print-architecture) Signed-By: /etc/apt/keyrings/docker.asc EOF
Grafana and Prometheus

Step 4. Install Docker and Docker Compose

Run:

sudo apt update

Install Docker:

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Enable Docker to start automatically on VPS boot:

sudo systemctl enable --now docker

Step 5. Create Grafana and Prometheus Directories

Create Prometheus directory:

sudo mkdir -p /opt/monitoring/prometheus

Create Grafana directory:

sudo mkdir -p /opt/monitoring/grafana/provisioning/datasources

Navigate to the Monitoring directory:

cd /opt/monitoring

Step 6. Create Prometheus Configuration

sudo tee prometheus/prometheus.yml >/dev/null <<'EOF' global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: prometheus static_configs: - targets: - '127.0.0.1:9090' - job_name: node static_configs: - targets: - '127.0.0.1:9100' EOF

Step 7. Create Prometheus Data Source for Grafana

We will configure Grafana to automatically discover Prometheus on startup.

sudo tee grafana/provisioning/datasources/datasource.yml >/dev/null <<'EOF' apiVersion: 1 datasources: - name: Prometheus type: prometheus access: proxy url: http://127.0.0.1:9090 isDefault: true editable: true EOF

Step 8. Create Grafana Admin Account

Run:

sudo tee .env >/dev/null <<EOF GF_SECURITY_ADMIN_USER=admin GF_SECURITY_ADMIN_PASSWORD=$(openssl rand -base64 24) EOF

Restrict file access permissions:

sudo chmod 600 .env

Step 9. Create Docker Compose

Create file:

sudo tee docker-compose.yml >/dev/null <<'EOF' services: prometheus: image: prom/prometheus:latest container_name: prometheus network_mode: host restart: unless-stopped volumes: - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--web.listen-address=127.0.0.1:9090' grafana: image: grafana/grafana:latest container_name: grafana network_mode: host restart: unless-stopped env_file: - .env volumes: - grafana_data:/var/lib/grafana - ./grafana/provisioning:/etc/grafana/provisioning node-exporter: image: quay.io/prometheus/node-exporter:latest container_name: node-exporter network_mode: host pid: host restart: unless-stopped command: - '--path.rootfs=/host' - '--web.listen-address=127.0.0.1:9100' volumes: - '/:/host:ro,rslave' volumes: prometheus_data: grafana_data: EOF

Step 10. Check configuration and start containers

Navigate to the Monitoring directory:

cd /opt/monitoring

Check Docker Compose file syntax:

sudo docker compose config

Start the containers:

sudo docker compose up -d

Then verify:

sudo docker compose ps
Grafana and Prometheus

Step 11. Log in to Grafana

 On your computer, open a browser and visit: http://IP_VPS:3000

User: admin

To view the Password again, run the command:

cd /opt/monitoring sudo cat .env
Grafana and Prometheus

Result:

GF_SECURITY_ADMIN_USER=admin

GF_SECURITY_ADMIN_PASSWORD=xxxxxxxxxxxxxxxx

Step 12. Import Node Exporter Dashboard

After logging into Grafana successfully, we will Import the DashboardNode Exporter Fullto visually monitor VPS resources such as CPU, RAM, Disk, Network, Load Average, and various other system metrics.

On the Grafana interface, select: Dashboards → New → Import

Grafana and Prometheus

In sectionImport dashboard, enter Dashboard ID: 1860

Then clickLoad.

Grafana and Prometheus

In the next step:

  • SelectPrometheusin the Data Source section.
  • Review Dashboard information again.
  • ClickImportto complete.

After successful Import, Grafana will display the DashboardNode Exporter Fullwith comprehensive resource monitoring charts for the VPS.

Grafana

You can monitor CPU Usage, RAM Usage, disk space, Network speed, Load Average, Disk I/O, and other system metrics right on an intuitive dashboard.

Grafana and Prometheus

You have now completed the installationPrometheus, Node Exporter, and Grafanato monitor VPS resources visually and effectively.

VPTS – Comprehensive Digital Infrastructure Solutions Provider

VPTS is a digital infrastructure solution provider in Vietnam, serving deployment, operation, and data storage needs for individuals, developers, and enterprises. The service ecosystem includesVietnam VPS, International VPS, VPS Anti DDoS, Hosting cPanel, dedicated server, Rack rental, Proxy IPv4/IPv6, S3 MinIOandCloud Storage.

Besides providing infrastructure resources, VPTS also focuses on assisting customers with deployment, configuration, and practical troubleshooting. Content on the VPTS Blog is drawn from common scenarios in operating VPS, servers, and online systems, helping readers understand root causes and apply clear solutions.

VPTS – Stable infrastructure, flexible solutions, and continuous partnership throughout operations.

VPTS Team Contact Information

CONCLUSION

Thus,VPTSguided you through completing the process ofinstall Grafana + Prometheus on Ubuntu VPS. Once successfully configured, you can visually monitor important server metrics such asCPU, RAM, disk space, system load, and VPS operational status.

The combination ofPrometheusandGrafanamakes system monitoring intuitive, easy to manage, and aids in early detection of resource or server performance issues.

For the monitoring system to operate stably and securely, regularly update software, configure the Firewall appropriately, use strong passwords, and set up alerts when VPS resources exceed predefined thresholds.

Hope this articleGuide to Installing Grafana + Prometheus on Ubuntu VPSofVPTSwill help you easily build an efficient and professional VPS monitoring system.