What I'm doing:
- Setting up three LXC containers in my Proxmox node.
- Prometheus
- prometheus-pve-exporter
- Grafana.
- pve-exporter will pull data from the Proxmox server
- Prometheus will pull the data from the pve-exporter container
- Grafana will pull from the Prometheus container and display it nice and pretty.
I assume you're already wondering why I would use three separate containers when I could just do this on one or even two. There's a few reasons, but the main one is that I prefer to have a bunch of small containers each doing one thing rather than a few larger containers each doing several things. Personal preference, but it works for me 🤷♀️
The following instructions assume you already have a Proxmox server up and running and know how to create LXC containers.
All the containers created in these steps are created with the Ubuntu Server 22.04 image.
Setting up the Prometheus container
2cpu, 2gb ram, 8gb storage. Calling this one 'prometheus'
The steps in this section are taken directly from samynitsche.de
Create a group/user
Create directories
Download/install Prometheus
Extract files and move to correct directory
Create systemd config
Paste in the following and save
Set permissions
Start Prometheus
You should now be able to go to http://<container-ip>:9090
and see the Prometheus instance running
Installing proxmox-pve-exporter
The following steps are a modified version of this post.
Create a new container
1cpu, 1gb ram, 6gb storage. Calling it 'prom-export'
Install pip3
Make directory for pve_exporter
Add Proxmox credentials
Add the following, but change to your Proxmox info
Save and exit
Test that it works
After running that in the console you should see something like:
Create systemd script
Add the following to the file:
Replace the IP address in that script with the IP of this container
Save and exit
Start pve_exporter service
Check that it's running with:
Back on the Prometheus container
Add the pve_exporter data to Prometheus
Add another job_name
after the line - targets: ["localhost:9000"]
Save and exit
Restart Prometheus
You should now be able to go to http://<prometheus-container-ip>:9090/targets
and see two entries. The first one is there by default, it's the Prometheus container. The second one should be the Proxmox metrics.
Setup Grafana
Make new container
2cpu, 2gb ram, 8gb storage. Calling it 'grafana'.
Setup apt for Grafana
Install Grafana
Start Grafana
Check that it's running
If everything looks good, you should be able to go to http://<grafana-container-ip>:3000
and see the login screen
Login with username/password admin
and create a new password.
Configure Grafana with Prometheus
Once logged in to Grafana:
- Click the gear icon at the bottom left
- Click the "Add data source" button
- Select Prometheus
- In the URL field, add the Prometheus container's IP and port like:
http://192.168.X.X:9090
- Click "Save and test"
Set up the pve-exporter dashboard
- Click the Dashboards icon on the left menu and select
+ Import
- In the textfield that says "Import via grafana.com" enter
10347
and click "Load" - Select Prometheus as the data source and save
Now you should have all your Proxmox metrics in this Grafana dashboard.
There's a chance that some of the labels may be overlapping and look all messed up. If so, just click the dropdown arrow at the top of that section and click "Edit". Expand the "Options" accordion and change the textfield that says {{name}}
to {{id}}
.
Refs: