I have a small Dell machine (Optiplex 5050) running Openwrt virtualized with Proxmox, and I noticed a while ago that my home network was sometimes lagging, and then I looked at the monitoring on Proxmox and found that the openwrt virtual machine was running at 100% CPU during this time, so no wonder it was very laggy.
I also have a small Dell machine (Optiplex 5080), which is also virtualized on Proxmox, and the two Dell’s add up to a total of 5 virtual machines, so it’s time to get on a monitor.
The community for Proxmox monitoring generally have Prometheus and influxdb two ways, I use here is Prometheus.
Like the Node exporter, a Proxmox exporter is also required, which can be used with the prometheus-pve-exporter project. The prometheus-pve-exporter calls Proxmox’s API to collect metrics, and then Prometheus then grabs the metrics data from the prometheus-pve-exporter and finally displays it through Grafana.
The prometheus-pve-exporter can be configured using either a configuration file or environment variables. Here I passed in
PVE_USER/PVE_PASSWORD/PVE_VERIFY_SSL to authenticate when calling the Proxmox API. Since this is a monitoring request, it is recommended to create a new read-only user on Proxmox instead of using root; creating a new user on Proxmox is easy and can be done on the page, but authorizing the user can only be done from the command line.
As follows, grant
PVEAuditor privileges to user
Note that the format of
user@pam, the difference between the two is that pve is a proxmox user, for example, I have a cluster of 2 Proxmoxes here, create a pve user to access 2 Proxmox machines; pam is a linux user, the username password may be different for different Proxmox machines (Proxmox is actually a Linux machine too).
PVE_VERIFY_SSL needs to be set to false, because it is a self-signed certificate.
prometheus-pve-exporter can be started directly or containerized. Because I want to use Prometheus for monitoring later, I deployed prometheus-pve-exporter to kubernetes and created a svc. Deployment is written similar to the following.
The created svc.
After prometheus-pve-exporter is started, metrics can be requested via http.
A prometheus-pve-exporter can request multiple Proxmox(targets).
I am using Prometheus Operator here, so just configure
ServiceMonitor. endpoints configure 2 Proxmox.
selector.matchLabels and the
pve-exporter created above should match up.
After the ServiceMonitor is created, Prometheus Operator will automatically refresh the Prometheus configuration, after which the pve monitoring information (e.g. pve_up) can be viewed on Prometheus.
Once the Proxmox data is collected in Prometheus, it is ready to be presented via Grafana. Here I am using Proxmox via Prometheus by Pietro Saccardi.
At this point, it is relatively easy to display the status of all Proxmox VMs in a unified way.