Skip to content

[!] add Prometheus exporter as a pgwatch source - #1405

Merged
pashagolub merged 33 commits into
masterfrom
prom-sources
Aug 6, 2026
Merged

[!] add Prometheus exporter as a pgwatch source#1405
pashagolub merged 33 commits into
masterfrom
prom-sources

Conversation

@pashagolub

Copy link
Copy Markdown
Collaborator

Allow pgwatch to scrape arbitrary Prometheus exporters, apply family-level filtering, and write measurements to any configured sink — including acting as a low-overhead proxy when the sink is a Prometheus endpoint.

@pashagolub pashagolub self-assigned this May 11, 2026
@pashagolub pashagolub added epic Large body of work broken down into a number of smaller issues sources What sources and in what way to monitor labels May 11, 2026
Comment thread internal/cmdopts/cmdsource.go Dismissed
@coveralls

coveralls commented May 11, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 31096149792

Coverage decreased (-1.0%) to 85.321%

Details

  • Coverage decreased (-1.0%) from the base build.
  • Patch coverage: 219 uncovered changes across 8 files (509 of 728 lines covered, 69.92%).
  • 18 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
internal/sources/conn.go 173 99 57.23%
internal/reaper/reaper.go 87 15 17.24%
internal/reaper/database.go 254 206 81.1%
internal/reaper/prometheus.go 107 98 91.59%
internal/testutil/http.go 8 0 0.0%
internal/cmdopts/cmdsource.go 13 10 76.92%
internal/sources/resolver.go 5 2 40.0%
internal/sinks/prometheus.go 40 38 95.0%
Total (14 files) 728 509 69.92%

Coverage Regressions

18 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
internal/reaper/database.go 16 88.47%
internal/reaper/reaper.go 2 49.59%

Coverage Stats

Coverage Status
Relevant Lines: 5852
Covered Lines: 4993
Line Coverage: 85.32%
Coverage Strength: 0.97 hits per line

💛 - Coveralls

@0xgouda

0xgouda commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Won't this be an unnecessary additional complexity, users can just use pgwatch as a prometheus exporter - which is a logical thing to do to avoid unnecessarily managing additional solution[s] - ?.

@pashagolub

Copy link
Copy Markdown
Collaborator Author

Won't this be an unnecessary additional complexity, users can just use pgwatch as a prometheus exporter - which is a logical thing to do to avoid unnecessarily managing additional solution[s] - ?.

I believe you miss the whole point of this feature. This is to fetch measurements from Prometheus, e.g. patroni

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xgouda check this out! :)

@pashagolub
pashagolub marked this pull request as ready for review August 5, 2026 17:31
@pashagolub pashagolub changed the title WIP: add Prometheus exporter as a pgwatch source [!] add Prometheus exporter as a pgwatch source Aug 5, 2026
- Add `SourceConn` interface with `Connect()`, `Ping(),
  `IsPostgresSource()`, `GetSource()`, `GetMetricInterval()`,
  `SetMetricIntervals()`, and `Close()` methods
- Rename `SourceConn` struct to `DbConn`; keep `NewSourceConn()` as a
  factory returning the interface, add `NewDbConn()` as the constructor
- Add `PromConn` stub struct implementing `SourceConn` for Prome sources
- Change `SourceConns` from []*SourceConn to interface slice
- Add `SourceRunner` interface in reaper package for worker abstraction
- Update `reaper.Reap()` to dispatch via type switch
- Update all callsites across reaper, sources, and cmdopts packages
Extend `WritePromMetrics()` and `AddCacheEntry()` to handle envelopes
whose SourceKind is 'prometheus' (the prom→prom proxy path):
@pashagolub
pashagolub merged commit 36d4a72 into master Aug 6, 2026
3 of 5 checks passed
@pashagolub
pashagolub deleted the prom-sources branch August 6, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

epic Large body of work broken down into a number of smaller issues sources What sources and in what way to monitor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants