Skip to content

feat!: add prepared statement metrics#194

Merged
SuperQ merged 4 commits intoprometheus-community:masterfrom
sboschman:ps-metrics
May 19, 2025
Merged

feat!: add prepared statement metrics#194
SuperQ merged 4 commits intoprometheus-community:masterfrom
sboschman:ps-metrics

Conversation

@sboschman
Copy link
Copy Markdown
Contributor

Add the client_parse_count, server_parse_count and bind_count metrics, which were introduced in PgBouncer 1.24 with #1192.

Please note that for collecting the data we switched from the SHOW STATS command to the SHOW STATS_TOTALS command. This command does not calculate the averages on the PgBouncer side, which we do not use in the exporter anyways. Saving a few PgBouncer cpu ticks.
This means the metric prefix pgbouncer_stats_ has changed to pgbouncer_stats_totals_, e.g. pgbouncer_stats_received_bytes_total is now pgbouncer_stats_totals_received_bytes_total.

fixes #134

Tested with PgBouncer 1.20.1 and 1.24.0

Signed-off-by: Sverre Boschman <1142569+sboschman@users.noreply.github.com>
Signed-off-by: Sverre Boschman <1142569+sboschman@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

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

Thanks!

It seems like STATS_TOTALS was introduced in pgbouncer 1.8. Would you mind adding a note to the README that we now require >= 1.8

Signed-off-by: Sverre Boschman <1142569+sboschman@users.noreply.github.com>
@sboschman sboschman requested a review from SuperQ May 19, 2025 07:51
@SuperQ SuperQ merged commit 473e17c into prometheus-community:master May 19, 2025
4 checks passed
SuperQ added a commit that referenced this pull request Jun 12, 2025
Notes:
- This version changes the connection behavior to create a new client
connection for each scrape. Previously a connection was created at startup.
- This version now requires PgBouncer >= 1.8.

* [CHANGE] Make connections per-scrape #214
* [FEATURE] Add prepared statement metrics #194
* [FEATURE] Add total_server_assignment_count metric #208

Signed-off-by: SuperQ <superq@gmail.com>
@SuperQ SuperQ mentioned this pull request Jun 12, 2025
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.

Please add new pgbouncer-v1.21.0 metrics related to prepared statements

2 participants