Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add option to export multiple pgbouncer instances #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maikelpoot
Copy link

Why this PR

We TCP load balance our connections over multiple (4+) pgbouncer instances/processes to increase stability and performance. We would like to switch from our own exporter to the prometheus-community exporter but would like to run only one exporter instance instead of an exporter per pgbouncer instance.

What does the PR do

This PR will add the option to export multiple pgbouncer instances with one exporter instance using a yaml config file.
All the options are documented within the example config.yaml within this repo.
This config file also add the option to start the exporter even if the connection fails on startup.

Extra labels

To differentiate the metrics for each pgbouncer instances, you MUST configure a unique label/value set for each instance.
As shown in the example, this can be as simple as setting a unique pgbouncer_instance value for each instance.

The extra labels per instance are merged with the common extra_labels where the instance value has precedence over the common value

Requirements:

  • Every instance must define the same labels
  • Every instance must define at least have one label with an unique value.

If there requirements are not met the exporter will fail startup.

Example

When using the config file:

must_connect_on_startup: false
extra_labels:
  environment: prod
pgbouncers:
  - dsn: postgresql://user:pass@localhost:6432/pgbouncer?sslmode=disable
    extra_labels:
      pgbouncer_instance: set1-0
  - dsn: postgresql://user:pass@localhost:6433/pgbouncer?sslmode=disable
    extra_labels:
      pgbouncer_instance: set1-1
  - dsn: postgresql://user:pass@localhost:6434/pgbouncer?sslmode=disable
    extra_labels:
      pgbouncer_instance: set1-2

you now get 3 pgbouncer_up metrics:

% curl -s http://localhost:9127/metrics | grep "_up"
# HELP pgbouncer_up The pgbouncer scrape succeeded
# TYPE pgbouncer_up gauge
pgbouncer_up{environment="prod",pgbouncer_instance="set1-0"} 1
pgbouncer_up{environment="prod",pgbouncer_instance="set1-1"} 1
pgbouncer_up{environment="prod",pgbouncer_instance="set1-2"} 0

@maikelpoot maikelpoot force-pushed the feature/multiple_scrape_endpoints branch from af1f42f to dba0cb1 Compare November 1, 2024 10:51
@maikelpoot
Copy link
Author

Force-push was to add sign-off to the commit

@maikelpoot maikelpoot changed the title Feat(config): add option to export multiple pgbouncer instances Feature: add option to export multiple pgbouncer instances Nov 1, 2024
@maikelpoot
Copy link
Author

@SuperQ Can i do something to add some progress the review process?

@garima-trivedi
Copy link

@SuperQ : This is definitely a useful and most wanted feature.
Or is there any other PR which is going to provide same feature. i.e. "Support to export metrics from multiple pgbouncer instances"
Please, can we expedite support for this feature?

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.

2 participants