Giter Club home page Giter Club logo

pbs-exporter's Introduction

Proxmox Backup Server Exporter

License GitHub go.mod Go version GitHub Workflow Status GitHub Workflow Status GitHub Workflow Status


Export Proxmox Backup Server statistics to Prometheus.

Metrics are retrieved using the Proxmox Backup Server API.

Exported Metrics

Metric Meaning Labels
pbs_up Was the last query of Proxmox Backup Server successful?
pbs_available The available bytes of the underlying storage. datastore
pbs_size The size of the underlying storage in bytes. datastore
pbs_used The used bytes of the underlying storage. datastore
pbs_snapshot_count The total number of backups. datastore, namespace
pbs_snapshot_vm_count The total number of backups per VM. datastore, namespace, vm_id, vm_name
pbs_snapshot_vm_last_timestamp The timestamp of the last backup of a VM. datastore, namespace, vm_id, vm_name
pbs_snapshot_vm_last_verify The verify status of the last backup of a VM. datastore, namespace, vm_id, vm_name
pbs_host_cpu_usage The CPU usage of the host.
pbs_host_memory_free The free memory of the host.
pbs_host_memory_total The total memory of the host.
pbs_host_memory_used The used memory of the host.
pbs_host_swap_free The free swap of the host.
pbs_host_swap_total The total swap of the host.
pbs_host_swap_used The used swap of the host.
pbs_host_disk_available The available disk of the local root disk in bytes.
pbs_host_disk_total The total disk of the local root disk in bytes.
pbs_host_disk_used The used disk of the local root disk in bytes.
pbs_host_uptime The uptime of the host.
pbs_host_io_wait The io wait of the host.
pbs_host_load1 The load for 1 minute of the host.
pbs_host_load5 The load for 5 minutes of the host.
pbs_host_load15 The load 15 minutes of the host.

Flags / Environment Variables

$ ./pbs-exporter -help

You can use the following flags to configure the exporter. All flags can also be set using environment variables. Environment variables take precedence over flags.

Flag Environment Variable Description Default
pbs.loglevl PBS_LOGLEVEL Log level (debug, info) info
pbs.api.token PBS_API_TOKEN API token to use for authentication
pbs.api.token.name PBS_API_TOKEN_NAME Name of the API token to use for authentication pbs-exporter
pbs.endpoint PBS_ENDPOINT Address of the Proxmox Backup Server http://localhost:8007 (if no parameter target set)
pbs.username PBS_USERNAME Username to use for authentication root@pam
pbs.timeout PBS_TIMEOUT Timeout for requests to Proxmox Backup Server 5s
pbs.insecure PBS_INSECURE Disable TLS certificate verification false
pbs.metrics-path PBS_METRICS_PATH Path under which to expose metrics /metrics
pbs.web.listen-address PBS_LISTEN_ADDRESS Address to listen on for web interface and telemetry :9101

Docker secrets

If you are using Docker secrets, you can use the following environment variables to set the path to the secrets:

Environment Variable Description
PBS_API_TOKEN_FILE Path to the API token file
PBS_API_TOKEN_NAME_FILE Path to the API token name file
PBS_USERNAME_FILE Path to the username file

See an example of how to use Docker secrets with Docker Compose in the docker-compose-secrets.yaml file.

The variables PBS_API_TOKEN, PBS_API_TOKEN_NAME, and PBS_USERNAME take precedence over the secret files.

Multiple Proxmox Backup Servers

If you want to monitor multiple Proxmox Backup Servers, you can use the targets parameter in the query string. Instead of setting the pbs.endpoint flag (or PBS_ENDPOINT env), you can use the target parameter in the query string to specify the Proxmox Backup Server to monitor. You would then use following URL to scrape metrics: http://localhost:9101/metrics?target=http://10.10.10.10:8007.

This is useful if you are using Prometheus and want to monitor multiple Proxmox Backup Servers with one "pbs-exporter" instance. You find examples for Prometheus static configuration in the prometheus/static-config directory.

⚠️ Important: if pbs.endpoint or PBS_ENDPOINT is set, the target parameter is ignored.

Node metrics

According to the api documentation, we have to provide a node name (won't work with the node ip), but it seems to work with any name, so we just use "localhost" for the request. This setup is tested with one proxmox backup server host.

Supported versions

We have only tested the exporter with Proxmox Backup Server version 2.X (see Proxmox Backup Server Roadmap). If you have already tested the exporter with a newer version, or have encountered problems, please let us know.

pbs-exporter's People

Contributors

chrisfromcnc avatar dependabot[bot] avatar janfuhrer avatar nalabelle avatar

Stargazers

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

Watchers

 avatar  avatar

pbs-exporter's Issues

Support multiple endpoints

Support multiple endpoints with one exporter like the prometheus-pve-exporter.

- job_name: 'pbs-exporter'
  static_configs:
    - targets:
      - <target-ip-1>
      - <target-ip-2>
  metrics_path: /metrics
  params:
    module: [default]
  relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: pbs-exporter:9101

pbs_up = 0 when datastore is being deleted

Hi

Exporter will set pbs_up = 0 when some datastore is being deleted
I think It does not make sense to set pbs_up = 0 because the proxmox backup server still working and can get other metrics.

I have created PR #7 to check datastore is being deleted.
I already check PBS API docs. It does seem not to have any paths to get its status.

Add secrets file support for docker

I propose to add support to dockerfile secrets for PBS_USERNAME, PBS_API_TOKEN_NAME and PBS_API_TOKEN.

Idea is to move secrets outside of docker-compose file for instance for security purpose.

As example a docker-compose file can be created like this:
proxmoxbackup:
image: ghcr.io/natrontech/pbs-exporter:0.1.5
container_name: proxmoxbackup
restart: always
secrets:
- proxmoxbackup-username
- proxmoxbackup-api-token-name
- proxmoxbackup-api-token
environment:
PBS_USERNAME_FILE: /run/secrets/proxmoxbackup-username
PBS_API_TOKEN_NAME_FILE: /run/secrets/proxmoxbackup-api-token-name
PBS_API_TOKEN_FILE: /run/secrets/proxmoxbackup-api-token

secrets:
proxmoxbackup-username:
file: "./.secrets/proxmoxbackup_username.secret"
proxmoxbackup-api-token-name:
file: "./.secrets/proxmoxbackup_api_token_name.secret"
proxmoxbackup-api-token:
file: "./.secrets/proxmoxbackup_api_token.secret"

All secrets are now stored in a folder .secrets.

Convention naming for secrets in docker is to add _FILE to regular environnement variable.
In our case we need to manage PBS_USERNAME_FILE, PBS_API_TOKEN_NAME_FILE and PBS_API_TOKEN_FILE env variables.

I just adapt the main.go to read the new env variable for the secret file name and read the first line from the file.

Sorry I cannot add a file here so I post a diff of main

diff --git a/main.go b/main.go
index 1e6686d..cd8cd88 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
package main

import (

  • "bufio"
    "crypto/tls"
    "encoding/json"
    "flag"
    @@ -234,6 +235,24 @@ type Exporter struct {
    authorizationHeader string
    }

+func ReadSecretFile(secretfilename string) string {

  • file, err := os.Open(secretfilename)
  • // flag to check the file format
  • if err != nil {
  •   log.Fatal(err)
    
  • }
  • // Close the file
  • defer func() {
  •   if err = file.Close(); err != nil {
    
  •   	log.Fatal(err)
    
  •   }
    
  • }()
  • // Read the first line
  • line := bufio.NewScanner(file)
  • line.Scan()
  • return line.Text()
    +}

func NewExporter(endpoint string, username string, apitoken string, apitokenname string) *Exporter {
return &Exporter{
endpoint: endpoint,
@@ -660,12 +679,24 @@ func main() {
}
if os.Getenv("PBS_USERNAME") != "" {
*username = os.Getenv("PBS_USERNAME")

  • } else {
  •   if os.Getenv("PBS_USERNAME_FILE") != "" {
    
  •   	*username = ReadSecretFile(os.Getenv("PBS_USERNAME_FILE"))
    
  •   }
    
    }
    if os.Getenv("PBS_API_TOKEN_NAME") != "" {
    *apitokenname = os.Getenv("PBS_API_TOKEN_NAME")
  • } else {
  •   if os.Getenv("PBS_API_TOKEN_NAME_FILE") != "" {
    
  •   	*apitokenname = ReadSecretFile(os.Getenv("PBS_API_TOKEN_NAME_FILE"))
    
  •   }
    
    }
    if os.Getenv("PBS_API_TOKEN") != "" {
    *apitoken = os.Getenv("PBS_API_TOKEN")
  • } else {
  •   if os.Getenv("PBS_API_TOKEN_FILE") != "" {
    
  •   	*apitoken = ReadSecretFile(os.Getenv("PBS_API_TOKEN_FILE"))
    
  •   }
    
    }
    if os.Getenv("PBS_TIMEOUT") != "" {
    *timeout = os.Getenv("PBS_TIMEOUT")

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.