Giter Club home page Giter Club logo

pbs-exporter's Introduction

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

  • curl
  • jq
  • Optional: make - for automatic installation support

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.

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:

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
  1. Copy the systemd unit and timer to $HOME/.config/systemd/user/:
cp pbs-exporter.* $HOME/.config/systemd/user/
  1. 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

With the Makefile

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

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/:

sudo cp pbs-exporter.* /etc/systemd/system/
  1. 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

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'
  • PBS_API_TOKEN_NAME should be the value in the "Token name" column in the Proxmox Backup Server user interface's Configuration - 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.
  • PBS_URL should be the same URL as used to access the Proxmox Backup Server user interface
  • PUSHGATEWAY_URL should be a valid URL for the push gateway.

Troubleshooting

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

Exported metrics per PBS store

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.

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.

make uninstall-user

Manually

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

With the Makefile

For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph.

sudo make uninstall

Manually

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

Credits

This project takes inspiration from the following:

pbs-exporter's People

Contributors

ntimo avatar rare-magma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pbs-exporter's Issues

pbs_snapshot_vm_count error metric: "pushed metrics are invalid or inconsistent with existing metrics"

Hello,
I just updated to the new version with snapshot metrics and now when I run the exporter I get this error:

an 07 16:32:33 pbs pbs_exporter.sh[196541]: pushed metrics are invalid or inconsistent with existing metrics: 7 error(s) occurred:
Jan 07 16:32:33 pbs pbs_exporter.sh[196541]: * collected metric "pbs_snapshot_vm_count" { label:<name:"host" value:"pbs" > label:<name:"instance" value:"" > label:<name:"job" value:"pbs_exporter" > label> was collected before with the same name and label values
Jan 07 16:32:33 pbs pbs_exporter.sh[196541]: * collected metric "pbs_snapshot_vm_count" { label:<name:"host" value:"pbs" > label:<name:"instance" value:"" > label:<name:"job" value:"pbs_exporter" > label> was collected before with the same name and label values

Metric for backup count per datastore

Hello,
I just found this awesome project and wanted to ask if it possible to add a metric that contains the backup counts per datastore or maybe even per vm id in the data store.

Thanks for creating this

Error in the executable, search for a Grafana Dashboard

Hi,

I had a problem as the executable searches the conf file in "$CREDENTIAL_DIR/cred", and the variable is set to the file ("/etc/pbs_credentials.conf"). The systemd always fails. Changing the executable to souce just "$CREDENTIAL_DIR" goes flawlessly I think

And... do you happen to have a Grafana Dashboard at hand?

Thank you very much,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.