Skip to content

WIP: add Prometheus exporter as a pgwatch source#1405

Draft
pashagolub wants to merge 27 commits into
masterfrom
prom-sources
Draft

WIP: add Prometheus exporter as a pgwatch source#1405
pashagolub wants to merge 27 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 25873338810

Coverage decreased (-1.1%) to 84.609%

Details

  • Coverage decreased (-1.1%) 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%

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 51.23%

Coverage Stats

Coverage Status
Relevant Lines: 5763
Covered Lines: 4876
Line Coverage: 84.61%
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 added 20 commits May 14, 2026 11:51
- 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):
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