Bash script that uploads proxmox backup server API info to prometheus' pushgateway on a daily basis.
-
Configure
pbs_exporter.conf
(see the configuration section below). -
Run it.
docker compose up --detach
-
Build the docker image.
docker build . --tag pbs-exporter
-
Configure
pbs_exporter.conf
(see the configuration section below). -
Run it.
docker run --rm --init --tty --interactive --volume $(pwd):/app localhost/pbs-exporter
As normal user
For convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph.
make install-user
$EDITOR $HOME/.config/pbs_exporter.conf
-
Copy
pbs_exporter.sh
to$HOME/.local/bin/
and make it executable. -
Copy
pbs_exporter.conf
to$HOME/.config/
, configure it (see the configuration section below) and make it read only. -
Edit pbs-exporter.service and change the following lines:
ExecStart=/usr/local/bin/pbs_exporter.sh
EnvironmentFile=/etc/pbs_exporter.conf
to
ExecStart=/home/%u/.local/bin/pbs_exporter.sh
EnvironmentFile=/home/%u/.config/pbs_exporter.conf
- Copy the systemd unit and timer to
$HOME/.config/systemd/user/
:
cp pbs-exporter.* $HOME/.config/systemd/user/
- and run the following command to activate the timer:
systemctl --user enable --now pbs-exporter.timer
It's possible to trigger the execution by running manually:
systemctl --user start pbs-exporter.service
As root
For convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph.
sudo make install
sudoedit /etc/pbs_exporter.conf
-
Copy
pbs_exporter.sh
to/usr/local/bin/
and make it executable. -
Copy
pbs_exporter.conf
to/etc/
, configure it (see the configuration section below) and make it read only. -
Copy the systemd unit and timer to
/etc/systemd/system/
:
sudo cp pbs-exporter.* /etc/systemd/system/
- and run the following command to activate the timer:
sudo systemctl enable --now pbs-exporter.timer
It's possible to trigger the execution by running manually:
sudo systemctl start pbs-exporter.service
The config file has a few options:
PBS_API_TOKEN_NAME='user@pam!prometheus'
PBS_API_TOKEN='123e4567-e89b-12d3-a456-426614174000'
PBS_URL='https://pbs.example.com'
PUSHGATEWAY_URL='https://pushgateway.example.com'
PBS_API_TOKEN_NAME
should be the value in the "Token name" column in the Proxmox Backup Server user interface'sConfiguration - Access Control - Api Token
page.PBS_API_TOKEN
should be the value shown when the API Token was created.- This token should have at least the
Datastore.Audit
access role assigned to it and the path set to/datastore
.
- This token should have at least the
PBS_URL
should be the same URL as used to access the Proxmox Backup Server user interfacePUSHGATEWAY_URL
should be a valid URL for the push gateway.
As normal user
Run the script manually with bash set to trace:
bash -x $HOME/.local/bin/pbs_exporter.sh
Check the systemd service logs and timer info with:
journalctl --user --unit pbs-exporter.service
systemctl --user list-timers
As root
Run the script manually with bash set to trace:
sudo bash -x /usr/local/bin/pbs_exporter.sh
Check the systemd service logs and timer info with:
journalctl --unit pbs-exporter.service
systemctl list-timers
The following metrics are available for all stores currently not in maintenance mode:
- pbs_available: The available bytes of the underlying storage.
- pbs_size: The size of the underlying storage in bytes.
- pbs_used: The used bytes of the underlying storage.
- pbs_snapshot_count: The total number of backups.
- pbs_snapshot_vm_count: The total number of backups per VM.
# HELP pbs_available The available bytes of the underlying storage.
# TYPE pbs_available gauge
# HELP pbs_size The size of the underlying storage in bytes.
# TYPE pbs_size gauge
# HELP pbs_used The used bytes of the underlying storage.
# TYPE pbs_used gauge
# HELP pbs_snapshot_count The total number of backups.
# TYPE pbs_snapshot_count gauge
# HELP pbs_snapshot_vm_count The total number of backups per VM.
# TYPE pbs_snapshot_vm_count gauge
pbs_available {host="pbs.example.com", store="store2"} 567317757952
pbs_size {host="pbs.example.com", store="store2"} 691587252224
pbs_used {host="pbs.example.com", store="store2"} 124269494272
pbs_snapshot_count {host="pbs.example.com", store="store2"} 295
pbs_snapshot_vm_count {host="pbs.example.com", store="store2", vm_id="101"} 11
pbs_snapshot_vm_count {host="pbs.example.com", store="store2", vm_id="102"} 12
pbs_snapshot_vm_count {host="pbs.example.com", store="store2", vm_id="103"} 10
As normal user
For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph.
make uninstall-user
Run the following command to deactivate the timer:
systemctl --user disable --now pbs-exporter.timer
Delete the following files:
$HOME/.local/bin/pbs_exporter.sh
$HOME/.config/pbs_exporter.conf
$HOME/.config/systemd/user/pbs-exporter.timer
$HOME/.config/systemd/user/pbs-exporter.service
As root
For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph.
sudo make uninstall
Run the following command to deactivate the timer:
sudo systemctl disable --now pbs-exporter.timer
Delete the following files:
/usr/local/bin/pbs_exporter.sh
/etc/pbs_exporter.conf
/etc/systemd/system/pbs-exporter.timer
/etc/systemd/system/pbs-exporter.service
This project takes inspiration from the following: