From 5fd0d95a9648c66fdcff2d0b70b186ba7f825813 Mon Sep 17 00:00:00 2001 From: Jan Fuhrer Date: Thu, 11 Apr 2024 17:37:01 +0200 Subject: [PATCH 1/2] feat: bump go to v1.22, update dependencies & workflow, improve git setup --- .github/dependabot.yml | 15 +++ .github/workflows/ci.yml | 6 +- .github/workflows/codeql.yml | 8 +- .github/workflows/docker-release.yml | 8 +- .pre-commit-config.yaml | 4 +- CODE_OF_CONDUCT.md | 128 ++++++++++++++++++ CONTRIBUTING.md | 17 +++ Dockerfile | 20 ++- README.md | 74 +++++------ SECURITY.md | 11 ++ docker-compose.yaml | 3 +- go.mod | 18 ++- go.sum | 43 +++---- grafana-dashboard/pbs-exporter.json | 53 +++++--- prometheus/example-rules.yaml | 185 +++++++++++++-------------- 15 files changed, 389 insertions(+), 204 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 SECURITY.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1f121c0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + commit-message: + prefix: ":robot:" + # GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: ":seedling:" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd9d133..d29dd31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,17 +13,17 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - goVer: [1.21] + goVer: [1.22] steps: - name: Set up Go ${{ matrix.goVer }} - uses: actions/setup-go@v1 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.goVer }} id: go - name: Check out code into the Go module directory - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Get dependencies run: | diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 083187a..5c84e5a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -40,11 +40,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -58,7 +58,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -71,6 +71,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 3279a38..dee6a0d 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -17,10 +17,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -28,12 +28,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + uses: docker/build-push-action@v5 with: context: . push: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1212963..20c4d1f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks.git - rev: v4.4.0 + rev: v4.6.0 hooks: - id: end-of-file-fixer exclude_types: ['markdown'] @@ -12,7 +12,7 @@ repos: - id: check-executables-have-shebangs - id: check-merge-conflict - repo: https://github.com/gitleaks/gitleaks - rev: v8.17.0 + rev: v8.18.2 hooks: - id: gitleaks - repo: https://github.com/dnephin/pre-commit-golang diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..ad33161 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +info@natron.io. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at +. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..501a7d8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish to make via issue, +email, or any other method with the owners of this repository before making a change. + +Please note we have a code of conduct, please follow it in all your interactions with the project. + +## Pull Request Process + +1. Ensure any install or build dependencies are removed before the end of the layer when doing a + build. +2. Update the README.md with details of changes to the interface, this includes new environment + variables, exposed ports, useful file locations and container parameters. +3. Increase the version numbers in any examples files and the README.md to the new version that this + Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). +4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you + do not have permission to do that, you may request the second reviewer to merge it for you. diff --git a/Dockerfile b/Dockerfile index 282fde1..0da44a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,20 @@ -FROM golang:1.21-alpine AS builder +FROM golang:1.22-alpine AS builder WORKDIR /build COPY go.mod go.sum main.go ./ RUN go mod tidy \ && CGO_ENABLED=0 go build -FROM alpine as runtime -COPY --from=builder /build/pbs-exporter /app/pbs-exporter -EXPOSE 9101 -CMD ["/app/pbs-exporter"] +FROM alpine:3.19 as runtime + +LABEL maintainer="natrontech" + +RUN addgroup -S app \ + && adduser -S -G app app + +WORKDIR /home/app +COPY --from=builder /build/pbs-exporter . +RUN chown -R app:app ./ + +USER app + +CMD ["./pbs-exporter"] diff --git a/README.md b/README.md index 3c3ed52..5677127 100644 --- a/README.md +++ b/README.md @@ -19,31 +19,31 @@ Metrics are retrieved using the [Proxmox Backup Server API](https://pbs.proxmox. ## 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. | | +| 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 @@ -53,18 +53,18 @@ $ ./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` | -| `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` | +| 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` | +| `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` | ## Node metrics -According to the [api documentation](https://pbs.proxmox.com/docs/api-viewer/index.html#/nodes/{node}), 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. \ No newline at end of file +According to the [api documentation](https://pbs.proxmox.com/docs/api-viewer/index.html#/nodes/{node}), 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. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..b2b8acd --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,11 @@ +# Security Policy + +## Supported Versions + +| Version | Supported | +| ------- | ------------------ | +| latest | :white_check_mark: | + +## Reporting a Vulnerability + +Open up an issue :) diff --git a/docker-compose.yaml b/docker-compose.yaml index d0bd93c..aba11fb 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,9 +5,10 @@ services: # image: ghcr.io/natrontech/pbs-exporter:latest container_name: pbs-exporter user: '65534' - restart: unless-stopped + restart: always ports: - "9101:9101" environment: - PBS_API_TOKEN= - PBS_ENDPOINT=https://pbs-server:8007 + - PBS_INSECURE=false diff --git a/go.mod b/go.mod index 2eecee1..0d96282 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,15 @@ module pbs-exporter -go 1.21 +go 1.22 -require github.com/prometheus/client_golang v1.16.0 +require github.com/prometheus/client_golang v1.19.0 require ( github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.11.1 // indirect - golang.org/x/sys v0.11.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.52.3 // indirect + github.com/prometheus/procfs v0.13.0 // indirect + golang.org/x/sys v0.19.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect ) diff --git a/go.sum b/go.sum index 9b9c425..32f58c4 100644 --- a/go.sum +++ b/go.sum @@ -1,31 +1,20 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= -github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.52.3 h1:5f8uj6ZwHSscOGNdIQg6OiZv/ybiK2CO2q2drVZAQSA= +github.com/prometheus/common v0.52.3/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= +github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= +github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/grafana-dashboard/pbs-exporter.json b/grafana-dashboard/pbs-exporter.json index 0558518..14e54e0 100644 --- a/grafana-dashboard/pbs-exporter.json +++ b/grafana-dashboard/pbs-exporter.json @@ -19,7 +19,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "id": 3, + "id": 12, "links": [], "liveNow": false, "panels": [ @@ -66,9 +66,11 @@ "fields": "", "values": false }, - "textMode": "auto" + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -257,7 +259,7 @@ } ] }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -406,9 +408,11 @@ "fields": "", "values": false }, - "textMode": "auto" + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -487,7 +491,7 @@ }, "showHeader": true }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -610,7 +614,7 @@ }, "showHeader": true }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -810,7 +814,7 @@ }, "showHeader": true }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -954,6 +958,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1050,6 +1055,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1184,6 +1190,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1323,6 +1330,8 @@ }, "id": 4, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -1332,9 +1341,10 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -1362,6 +1372,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1501,6 +1512,8 @@ }, "id": 19, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -1510,9 +1523,10 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -1553,6 +1567,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1649,6 +1664,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1743,7 +1759,6 @@ } ], "title": "Root Disk Space Usage", - "transformations": [], "type": "timeseries" }, { @@ -1787,6 +1802,8 @@ }, "id": 10, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -1796,9 +1813,10 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "10.1.1", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -1817,8 +1835,7 @@ } ], "refresh": "30s", - "schemaVersion": 38, - "style": "dark", + "schemaVersion": 39, "tags": [ "proxmox" ], diff --git a/prometheus/example-rules.yaml b/prometheus/example-rules.yaml index 51bc869..5fe68e9 100644 --- a/prometheus/example-rules.yaml +++ b/prometheus/example-rules.yaml @@ -1,106 +1,105 @@ groups: + - name: ProxmoxBackupServer.rules -- name: ProxmoxBackupServer.rules + rules: + - alert: ProxmoxBackupHostDown + expr: "absent(pbs_available)" + for: 2m + labels: + severity: warning + annotations: + summary: Proxmox Backup Server down + description: "Proxmox Backup Server {{ $labels.instance }} is not available." - rules: + - alert: ProxmoxBackupSnapshotVerifyFailed + expr: 'sum by (vm_id) (max_over_time(pbs_snapshot_vm_last_verify[2d]) and pbs_snapshot_vm_count > 1) == 0' + for: 2m + labels: + severity: warning + annotations: + summary: Last verified Proxmox snapshot older than 2 days + description: "Last verified snapshot of vm {{ $labels.vm_name }} is older than 2 days." - - alert: ProxmoxBackupHostDown - expr: 'absent(pbs_available)' - for: 2m - labels: - severity: warning - annotations: - summary: Proxmox Backup Server down - description: "Proxmox Backup Server {{ $labels.instance }} is not available." + - alert: ProxmoxBackupSnapshotOutdated + expr: '(time() - avg_over_time(pbs_snapshot_vm_last_timestamp[5m])) / 3600 / 24 > 2' + for: 2m + labels: + severity: warning + annotations: + summary: Last snapshot of vm is older than 2 days + description: "Last snapshot of vm {{ $labels.vm_name }} is older than 2 days." - - alert: ProxmoxBackupSnapshotVerifyFailed - expr: 'sum by (vm_id) (max_over_time(pbs_snapshot_vm_last_verify[2d]) and pbs_snapshot_vm_count > 1) == 0' - for: 2m - labels: - severity: warning - annotations: - summary: Last verified Proxmox snapshot older than 2 days - description: "Last verified snapshot of vm {{ $labels.vm_name }} is older than 2 days." + - alert: ProxmoxBackupPoolDiskOutOfSpace + expr: "pbs_used / pbs_size * 100 > 90" + for: 2m + labels: + severity: warning + annotations: + summary: Proxmox datastore out of space (datastore {{ $labels.datastore }}) + description: "Disk is almost full (< 10% left)\n VALUE = {{ $value }}" - - alert: ProxmoxBackupSnapshotOutdated - expr: '(time() - pbs_snapshot_vm_last_timestamp) / 3600 / 24 > 2' - for: 2m - labels: - severity: warning - annotations: - summary: Last snapshot of vm is older than 2 days - description: "Last snapshot of vm {{ $labels.vm_name }} is older than 2 days." + - alert: ProxmoxBackupPoolDiskFillingUpInFourDays + annotations: + description: Based on recent sampling, the datastore {{ $labels.datastore }} is expected to fill up withing four days. Currently {{ $value | humanizePercentage }} is available. + summary: Proxmox datastore is filling up. + expr: pbs_used / pbs_size > 0.7 and pbs_used > 0 and predict_linear(pbs_available[6h], 4 * 24 * 3600) < 0 + for: 30m + labels: + severity: warning - - alert: ProxmoxBackupPoolDiskOutOfSpace - expr: 'pbs_used / pbs_size * 100 > 90' - for: 2m - labels: - severity: warning - annotations: - summary: Proxmox datastore out of space (datastore {{ $labels.datastore }}) - description: "Disk is almost full (< 10% left)\n VALUE = {{ $value }}" + - alert: ProxmoxBackupRootDiskOutOfSpace + expr: "pbs_host_disk_used / pbs_host_disk_total * 100 > 90" + for: 2m + labels: + severity: warning + annotations: + summary: Proxmox root disk out of space (instance {{ $labels.instance }}) + description: "Disk is almost full (< 10% left)\n VALUE = {{ $value }}" - - alert: ProxmoxBackupPoolDiskFillingUp - annotations: - description: Based on recent sampling, the datastore {{ $.labels.datastore }} is expected to fill up withing four days. Currently {{ $value | humanizePercentage }} is available. - summary: Proxmox datastore is filling up. - expr: pbs_used / pbs_size > 0.6 and pbs_used > 0 and predict_linear(pbs_available[6h], 4 * 24 * 3600) < 0 - for: 30m - labels: - severity: warning + - alert: ProxmoxBackupRootDiskFillingUpInFourDays + annotations: + description: Based on recent sampling, the root disk {{ $labels.instance }} is expected to fill up withing four days. Currently {{ $value | humanizePercentage }} is available. + summary: Proxmox root disk is filling up. + expr: + pbs_host_disk_used / pbs_host_disk_total > 0.7 and pbs_host_disk_used > 0 and + predict_linear(pbs_host_disk_available[6h], 4 * 24 * 3600) < 0 + for: 30m + labels: + severity: warning - - alert: ProxmoxBackupRootDiskOutOfSpace - expr: 'pbs_host_disk_used / pbs_host_disk_total * 100 > 90' - for: 2m - labels: - severity: warning - annotations: - summary: Proxmox root disk out of space (instance {{ $labels.instance }}) - description: "Disk is almost full (< 10% left)\n VALUE = {{ $value }}" + - alert: ProxmoxBackupHostOutOfMemory + expr: "pbs_host_memory_used / (pbs_host_memory_used + pbs_host_memory_free) * 100 > 90" + for: 2m + labels: + severity: warning + annotations: + summary: Proxmox host out of memory (instance {{ $labels.instance }}) + description: "Node memory is filling up (< 10% left)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" - - alert: ProxmoxBackupRootDiskFillingUp - annotations: - description: Based on recent sampling, the root disk {{ $.labels.instance }} is expected to fill up withing four days. Currently {{ $value | humanizePercentage }} is available. - summary: Proxmox root disk is filling up. - expr: pbs_host_disk_used / pbs_host_disk_total > 0.6 and pbs_host_disk_used > 0 and - predict_linear(pbs_host_disk_available[6h], 4 * 24 * 3600) < 0 - for: 30m - labels: - severity: warning + - alert: ProxmoxBackupHostSwapIsFillingUp + expr: "pbs_host_swap_used / (pbs_host_swap_used + pbs_host_swap_free) * 100 > 80" + for: 2m + labels: + severity: warning + annotations: + summary: Proxmox host swap is filling up (instance {{ $labels.instance }}) + description: "Swap is filling up (> 80%)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" - - alert: ProxmoxBackupHostOutOfMemory - expr: 'pbs_host_memory_used / (pbs_host_memory_used + pbs_host_memory_free) * 100 > 90' - for: 2m - labels: - severity: warning - annotations: - summary: Proxmox host out of memory (instance {{ $labels.instance }}) - description: "Node memory is filling up (< 10% left)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + - alert: ProxmoxBackupHostHighCpuLoad + expr: "avg_over_time(pbs_host_cpu_usage[2m]) > 0.8" + for: 10m + labels: + severity: warning + annotations: + summary: Host high CPU load (id {{ $labels.id }}) - - alert: ProxmoxBackupHostSwapIsFillingUp - expr: 'pbs_host_swap_used / (pbs_host_swap_used + pbs_host_swap_free) * 100 > 80' - for: 2m - labels: - severity: warning - annotations: - summary: Proxmox host swap is filling up (instance {{ $labels.instance }}) - description: "Swap is filling up (> 80%)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + description: "CPU load is > 80%\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" - - alert: ProxmoxBackupHostHighCpuLoad - expr: 'avg_over_time(pbs_host_cpu_usage[2m]) > 0.8' - for: 10m - labels: - severity: warning - annotations: - summary: Host high CPU load (id {{ $labels.id }}) - - description: "CPU load is > 80%\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" - - - alert: ProxmoxBackupHostHighIowait - expr: 'avg by (instance) (rate(pbs_host_io_wait[5m]) * 100) > 10' - for: 0m - labels: - severity: warning - annotations: - summary: Host CPU high iowait (instance {{ $labels.instance }}) - description: "CPU iowait > 10%. A high iowait means that you are disk or network bound.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" + - alert: ProxmoxBackupHostHighIowait + expr: "avg by (instance) (rate(pbs_host_io_wait[5m]) * 100) > 10" + for: 0m + labels: + severity: warning + annotations: + summary: Host CPU high iowait (instance {{ $labels.instance }}) + description: "CPU iowait > 10%. A high iowait means that you are disk or network bound.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}" From 183b6cd149baa4afc3cf17a4ccd0a8978e1d6b79 Mon Sep 17 00:00:00 2001 From: Jan Fuhrer Date: Thu, 11 Apr 2024 17:48:39 +0200 Subject: [PATCH 2/2] fix: test codeql action with fix go version --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0d96282..89de443 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module pbs-exporter -go 1.22 +go 1.22.2 require github.com/prometheus/client_golang v1.19.0