Skip to content

Add gpbackup_exporter — a Prometheus exporter for gpbackup history database.#87

Open
woblerr wants to merge 6 commits intoapache:mainfrom
woblerr:add_gpbackup_exporter
Open

Add gpbackup_exporter — a Prometheus exporter for gpbackup history database.#87
woblerr wants to merge 6 commits intoapache:mainfrom
woblerr:add_gpbackup_exporter

Conversation

@woblerr
Copy link
Copy Markdown
Collaborator

@woblerr woblerr commented Apr 13, 2026

Added gpbackup_exporter - a Prometheus exporter for collecting metrics from the gpbackup history database (gpbackup_history.db).

It is based on the original gpbackup_exporter project and has been adapted for integration into the cloudberry-backup repository.

Motivation

gpbackup does not expose built-in Prometheus metrics. gpbackup_exporter fills this gap. This allows integrating backup health monitoring into existing Prometheus/Grafana stacks.

Features

gpbackup_exporter exposes the following Prometheus metrics:

Backup metrics:

  • gpbackup_backup_status — backup status (success / failure);
  • gpbackup_backup_deletion_status — backup deletion status;
  • gpbackup_backup_info — backup info (version, compression, plugin, etc.);
  • gpbackup_backup_duration_seconds — backup duration in seconds.

Last backup metrics:

  • gpbackup_backup_since_last_completion_seconds — seconds elapsed since the last completed backup per database and backup type.

Exporter self-metrics:

  • gpbackup_exporter_status — gpbackup exporter get data status;
  • gpbackup_exporter_build_info — information about gpbackup exporter.

Filtering flags:

  • --gpbackup.db-include / --gpbackup.db-exclude — limit collection to specific databases;
  • --gpbackup.backup-type — limit collection to a specific backup type;
  • --gpbackup.collect-deleted / --gpbackup.collect-failed — include deleted / failed backups;
  • --collect.depth — collect metrics only for backups not older than N days;
  • --web.config.file — TLS and basic authentication support via the Prometheus exporter toolkit.

Verification

Unit tests pass without errors:

$ make unit

[1776080594] TOC Suite - 45/45 specs ••••••••••••••••••••••••••••••••••••••••••••• SUCCESS! 2.217417ms PASS
[1776080594] testutils tests - 8/8 specs •••••••• SUCCESS! 552.083µs PASS
[1776080594] Textmsg Suite - 14/14 specs •••••••••••••• SUCCESS! 604.292µs PASS
[1776080594] Gpbckpconfig Suite - 47/47 specs ••••••••••••••••••••••••••••••••••••••••••••••• SUCCESS! 1.909583ms PASS
[1776080594] utils tests - 118/118 specs •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• SUCCESS! 103.433167ms PASS
[1776080594] restore tests - 118/118 specs •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• SUCCESS! 85.166959ms PASS
[1776080594] Cmd Suite - 14/14 specs •••••••••••••• SUCCESS! 3.561667ms PASS
[1776080594] Filepath Suite - 31/31 specs ••••••••••••••••••••••••••••••• SUCCESS! 2.903958ms PASS
[1776080594] Options Suite - 27/27 specs ••••••••••••••••••••••••••• SUCCESS! 6.135125ms PASS
[1776080594] Exporter Suite - 37/37 specs ••••••••••••••••••••••••••••••••••••• SUCCESS! 18.97375ms PASS
[1776080594] History Suite - 8/8 specs •••••••• SUCCESS! 15.766416ms PASS
[1776080594] Report Suite - 34/34 specs •••••••••••••••••••••••••••••••••• SUCCESS! 9.29725ms PASS
[1776080594] s3_plugin tests - 32/32 specs •••••••••••••••••••••••••••••••• SUCCESS! 4.222791ms PASS
[1776080594] backup tests - 585/586 specs •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••S••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••S••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••S••••••••••••••••••••••••••••••••S••••••••••••••••••••••P••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••S••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••S•• SUCCESS! 172.169042ms PASS

Ginkgo ran 14 suites in 10.961838459s
Test Suite Passed

Open Questions

  1. The exporter uses promslog for logging, which outputs in logfmt or json format — the standard for Prometheus exporters. Other tools in this repository use gplog from cloudberry-go-libs. Should gpbackup_exporter be migrated to gplog for consistency, or is it acceptable to keep the Prometheus logger?

  2. The exporter's Makefile targets use additional -ldflags (GIT_REVISION, GIT_BRANCH, BUILD_DATE) injected into github.com/prometheus/common/version. This is required by the Prometheus exporter convention to populate gpbackup_exporter_build_info metric. Other tools in the repo use a simpler single -X version=... flag pattern. Is this acceptable?

Related links

woblerr added 6 commits April 11, 2026 17:35
Introduce the Prometheus metrics exporter as a new standalone binary within the repository.

- Create gpbackup_exporter.go entry point with CLI flags and collection loop.
- Port core exporter logic to the new `exporter/` package.
- Adapt type system to use `*history.BackupConfig` directly, aligning with the cloudberry-backup architecture.
- Switch receiver methods to standalone gpbckpconfig helpers.
- Add Prometheus and Kingpin dependencies to `go.mod`.
- Update Makefile to support building, testing, and packaging.
- Port unit tests to Ginkgo/Gomega.
Add e2e test that runs  gpbackup commands and validates that gpbackup_exporter correctly reads history database and exposes metrics.

Also remove dead gpbackmanPath assignment from useOldBackupVersion in e2e tests.
And suppress noisy test logger output by writing to bytes.Buffer instead of os.Stdout in exporter unit tests.
@woblerr woblerr requested review from robertmu and tuhaihe April 13, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant