rare-magma / pbs-exporter

Bash script that uploads proxmox backup server API info to prometheus' pushgateway.
Apache License 2.0
22 stars 5 forks source link
backup grafana grafana-dashboard prometheus prometheus-exporter proxmox proxmox-backup-server

pbs-exporter

I no longer use proxmox backup server so development of this tool has ceased. Feel free to fork it

Bash script that uploads proxmox backup server API info to prometheus' pushgateway on a daily basis.

Dependencies

Relevant documentation

Installation

With Docker

docker-compose

  1. Configure pbs_exporter.conf (see the configuration section below).
  2. Run it.

    docker compose up --detach

docker build & run

  1. Build the docker image.

    docker build . --tag pbs-exporter
  2. Configure pbs_exporter.conf (see the configuration section below).

  3. Run it.

    docker run --rm --init --tty --interactive --volume $(pwd):/app localhost/pbs-exporter

As normal user ### With the Makefile For convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph. ```bash make install-user $EDITOR $HOME/.config/pbs_exporter.conf ``` ### Manually 1. Copy `pbs_exporter.sh` to `$HOME/.local/bin/` and make it executable. 2. Copy `pbs_exporter.conf` to `$HOME/.config/`, configure it (see the configuration section below) and make it read only. 3. Edit pbs-exporter.service and change the following lines: ```bash ExecStart=/usr/local/bin/pbs_exporter.sh EnvironmentFile=/etc/pbs_exporter.conf ``` to ```bash ExecStart=/home/%u/.local/bin/pbs_exporter.sh EnvironmentFile=/home/%u/.config/pbs_exporter.conf ``` 4. Copy the systemd unit and timer to `$HOME/.config/systemd/user/`: ```bash cp pbs-exporter.* $HOME/.config/systemd/user/ ``` 5. and run the following command to activate the timer: ```bash systemctl --user enable --now pbs-exporter.timer ``` It's possible to trigger the execution by running manually: ```bash systemctl --user start pbs-exporter.service ```
As root ### With the Makefile For convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph. ```bash sudo make install sudoedit /etc/pbs_exporter.conf ``` ### Manually 1. Copy `pbs_exporter.sh` to `/usr/local/bin/` and make it executable. 2. Copy `pbs_exporter.conf` to `/etc/`, configure it (see the configuration section below) and make it read only. 3. Copy the systemd unit and timer to `/etc/systemd/system/`: ```bash sudo cp pbs-exporter.* /etc/systemd/system/ ``` 4. and run the following command to activate the timer: ```bash sudo systemctl enable --now pbs-exporter.timer ``` It's possible to trigger the execution by running manually: ```bash sudo systemctl start pbs-exporter.service ```


Config file

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'

Troubleshooting

As normal user Run the script manually with bash set to trace: ```bash bash -x $HOME/.local/bin/pbs_exporter.sh ``` Check the systemd service logs and timer info with: ```bash journalctl --user --unit pbs-exporter.service systemctl --user list-timers ```
As root Run the script manually with bash set to trace: ```bash sudo bash -x /usr/local/bin/pbs_exporter.sh ``` Check the systemd service logs and timer info with: ```bash journalctl --unit pbs-exporter.service systemctl list-timers ```


Exported metrics per PBS store

The following metrics are available for all stores currently not in maintenance mode:

Exported metrics example

# 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

Uninstallation

As normal user ### With the Makefile For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph. ```bash make uninstall-user ``` ### Manually Run the following command to deactivate the timer: ```bash systemctl --user disable --now pbs-exporter.timer ``` Delete the following files: ```bash $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 ### With the Makefile For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph. ```bash sudo make uninstall ``` ### Manually Run the following command to deactivate the timer: ```bash sudo systemctl disable --now pbs-exporter.timer ``` Delete the following files: ```bash /usr/local/bin/pbs_exporter.sh /etc/pbs_exporter.conf /etc/systemd/system/pbs-exporter.timer /etc/systemd/system/pbs-exporter.service ```


Credits

This project takes inspiration from the following: