Installing Grafana & Prometheus for Proxmox Monitoring
In my previous post, I walked through the basics of setting up Prometheus on Proxmox for monitoring. If you haven't seen that yet, I recommend checking it out. This post is essentially Step 2 in the process.
Here, I’ll share how I configured my containers during the initial setup. Admittedly, I pulled my settings from a variety of sources over time, so I can’t credit any one in particular—but this is what ended up working for me.
Without going into much detail. Let's get right into it.
Clone it here:
https://github.com/phipcode/phiptechblog/tree/main/monitoring/prometheus-grafana
File Structure
prometheus-grafana/
├── docker-compose.yml
├── prometheus/
│ ├── prometheus.yml
│ ├── entrypoint.sh
│ └── pve.yml
├── grafana/
│ └── datasource.yml
The Docker Compose File
What the Docker compose file does essentially is deploy both the Prometheus image and the Grafana image, and maps Prometheus as a data source in Grafana automatically
Persistent Storage: Both Prometheus and Grafana use Docker volumes (prom_data, grafana_data) to ensure your data and dashboards survive container restarts.
Health Checks & Logging:
Both services have health checks and log rotation configured for reliability and easier troubleshooting.
docker-compose.yml
services:
prometheus:
image: prom/prometheus:latest # Pinning image version
container_name: prometheus
entrypoint: /bin/sh -c /etc/prometheus/entrypoint.sh
ports:
- 9090:9090
restart: unless-stopped
volumes:
- ./prometheus:/etc/prometheus
- ./prometheus/pve.yml:/etc/prometheus/pve.yml # Mount the pve.yml credentials file
- prom_data:/prometheus
networks:
- monitoring
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://localhost:9090 || exit 1"]
interval: 30s
timeout: 5s
retries: 3
logging:
options:
max-size: "10m"
max-file: "3"
grafana:
image: grafana/grafana:latest # Pinning image version
container_name: grafana
ports:
- 3000:3000
restart: unless-stopped
volumes:
- ./grafana:/etc/grafana/provisioning/datasources
- grafana_data:/var/lib/grafana
networks:
- monitoring
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://localhost:3000 || exit 1"]
interval: 30s
timeout: 5s
retries: 3
logging:
options:
max-size: "10m"
max-file: "3"
volumes:
prom_data:
grafana_data:
networks:
monitoring:
Create the folders for Grafana and Prometheus
grafana/datasource.yml
- Creates the data source on your Grafana service.
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
access: proxy
editable: true
prometheus/entrypoint.sh
- Creates the service file for Proxmox VE Exporter and sets the permissions
#!/bin/sh
# Create the Proxmox Exporter systemd service file
cat < /etc/systemd/system/prometheus-pve-exporter.service
[Unit]
Description=Prometheus Proxmox VE Exporter
Documentation=https://github.com/prometheus-pve/prometheus-pve-exporter
[Service]
Restart=always
User=pve-exporter
ExecStart=/opt/prometheus-pve-exporter/bin/pve_exporter --config.file /etc/prometheus/pve.yml
[Install]
WantedBy=multi-user.target
EOL
# Set permissions for the service file
chown root:root /etc/systemd/system/prometheus-pve-exporter.service
chmod 644 /etc/systemd/system/prometheus-pve-exporter.service
# Set ownership and permissions for pve.yml
chown -v root:pve-exporter /etc/prometheus/pve.yml
chmod -v 640 /etc/prometheus/pve.yml
# Start Prometheus
exec prometheus --config.file=/etc/prometheus/prometheus.yml
prometheus/promethus.yml
- This is the config file for the Prometheus server. Modify as required. Ensure you change the target IP to your Proxmox server
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets: []
scheme: http
timeout: 10s
api_version: v2
scrape_configs:
- job_name: prometheus
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- localhost:9090
- job_name: 'pve-exporter'
static_configs:
- targets:
- 192.168.0.46:9221
metrics_path: /pve
params:
module: [default]
prometheus/pve.yml
- These are the credentials for Proxmox VE Exporter. Change the username and password you created in the previous guide
default:
user: pve-exporter@pve
password: "yourpasswordhere"
verify_ssl: false
Permissions
Before we deploy it, make sure your pve.yml config file has the right permissions to execute. Use the below command
chmod 600 ./prometheus/pve.yml

Run the containers
Finally, run your containers using the Docker Compose command.
docker compose up -d

Log in and change your password
The default credentials are admin for username and admin for password
Once you're in, navigate to Data sources, and you'll see the data source has been added for Prometheus

Click on the data source and validate that it can reach the Prometheus service

You've successfully configured Prometheus and Grafana containers for Proxmox. Make sure you follow the previous guide for setting up Proxmox monitoring

Found this article useful? Why not buy Phi a coffee to show your appreciation?