Application Guides

How can we help?

Guides and technical documentation for your Server4You dedicated server or VPS.

Prometheus LogoGrafana Logo

Install Prometheus & Grafana with Docker

This guide shows how to set up server monitoring with Prometheus, Grafana and Node Exporter via Docker Compose. Prometheus collects CPU, RAM, disk and network metrics, and Grafana displays them in dashboards.

Prerequisites:
✓ A server running a current Linux distribution (e.g. Ubuntu 24.04 or Debian 13)
✓ Docker and Docker Compose installed on the server
✓ A domain name pointing to your server's IP address (recommended for accessing Grafana)

Step 1: Create the Directory Structure and Configuration

Create a directory for your monitoring stack with subdirectories for the Prometheus configuration and the data. The data directories are assigned to the users the containers run as (Prometheus: UID 65534, Grafana: UID 472):

Create Directories
mkdir monitoring-stack && cd monitoring-stack mkdir prometheus_config prometheus_data grafana_data chown 65534:65534 prometheus_data chown 472:0 grafana_data

Now create the Prometheus configuration file:

Open Prometheus Config File
nano prometheus_config/prometheus.yml

Paste the following base configuration. It instructs Prometheus to monitor itself and the Node Exporter, which we will set up in the next step:

prometheus.yml
global: scrape_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node-exporter' static_configs: - targets: ['node-exporter:9100']

Step 2: Create the Docker Compose File

In the root of your monitoring-stack directory, create the Compose file:

Open Docker Compose File
nano docker-compose.yml

Paste the following content. The file defines three services: Prometheus for metric collection, Grafana for visualization, and Node Exporter which exposes your server's metrics:

docker-compose.yml
services: prometheus: image: prom/prometheus:latest container_name: prometheus restart: unless-stopped volumes: - ./prometheus_config:/etc/prometheus - ./prometheus_data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' ports: - '9090:9090' grafana: image: grafana/grafana-oss:latest container_name: grafana restart: unless-stopped volumes: - ./grafana_data:/var/lib/grafana ports: - '3000:3000' node-exporter: image: prom/node-exporter:latest container_name: node-exporter restart: unless-stopped volumes: - /proc:/host/proc:ro - /sys:/host/sys:ro - /:/rootfs:ro command: - '--path.procfs=/host/proc' - '--path.sysfs=/host/sys' - '--path.rootfs=/rootfs' - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'

Step 3: Start the Monitoring Stack

Start all three containers with a single command:

Start Docker Compose
docker compose up -d

Docker will pull the images and start Prometheus, Grafana, and Node Exporter in the background.

Step 4: Connect Grafana to Prometheus

Open your browser and navigate to http://YOUR_SERVER_IP:3000. Log in with the default credentials — username admin, password admin. You will be prompted to set a new password immediately.

1.Navigate to Connections → Data Sources in the left menu
2.Click Add data source and select Prometheus
3.Enter http://prometheus:9090 as the Prometheus server URL
4.Click Save & test — a green checkmark confirms the connection is working

Step 5: Import a Dashboard

Import a pre-built dashboard to start visualizing your server metrics right away:

1.Navigate to Dashboards → New → Import in the left menu
2.Enter dashboard ID 1860 — a widely used dashboard for server monitoring
3.Click Load and select your Prometheus data source on the next screen
4.Click Import — you will now see a full dashboard with CPU, RAM, disk, and network usage for your server

Further Documentation

For advanced configurations, custom dashboards, and alerting setup, refer to the official documentation for each tool.