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

Support "--auto-discover-databases" feature with postgres_exporter queries #323

Closed
kwould opened this issue Mar 2, 2023 · 5 comments
Closed
Labels
UNCONFIRMED Initial state. Need's triaged

Comments

@kwould
Copy link

kwould commented Mar 2, 2023

Describe the enhancement you are proposing:
Postgres_exporter has a flag you can enable called --auto-discover-databeses where it allows you to dynamically run queries on the databases that are inside the postgres instance (https://github.com/prometheus-community/postgres_exporter#automatically-discover-databases).
As a workaround to support these queries, they need to be updated to utilize current_database() to add the extra label of which database the query is being ran on. It would be nice if given the current file structure we had db specific and instance specific queries so that it's easier to segment.

I'm happy to work on this, I just wanted to first see if this was something that would be worthwhile.

@kwould kwould added the UNCONFIRMED Initial state. Need's triaged label Mar 2, 2023
@keithf4
Copy link
Collaborator

keithf4 commented Mar 2, 2023

I've seen quite a few open issues surrounding this auto-discovery feature so I've been avoiding it myself. Below are just a few of the ones still open

prometheus-community/postgres_exporter#588
prometheus-community/postgres_exporter#753
prometheus-community/postgres_exporter#750
prometheus-community/postgres_exporter#735

@kwould
Copy link
Author

kwould commented Mar 2, 2023

Thanks for the quick response @keithf4, anecdotally, most of those issues I saw due to having improperly configured queries. For my use case it would be sufficient enough if queries were segmented by files so that db specific queries lived in a seperate file compared to instance specific ones. This seems to fall with a similar pattern to how global queries are currently constructed.
Would that break anything?

@keithf4
Copy link
Collaborator

keithf4 commented Mar 2, 2023

So we already have our queries segmented to global and per-db. And our per-db queries already have the current_database() specification.

https://github.com/CrunchyData/pgmonitor/blob/development/postgres_exporter/common/queries_per_db.yml

So if you want to try using the --auto-discover-databeses with the exporter that's running the per_db queries, that might just work with how things are and just customizing your sysconfig file.

I don't want to the have the global queries running against all the databases. That just ends up duplicating metrics for every database that exists.

@keithf4
Copy link
Collaborator

keithf4 commented Mar 17, 2023

Did this answer your question on using this feature? I don't think we'll be enabling that option by default in pgMonitor, but I think it should work for the per-db exporter if anyone wants to use it there.

@kwould
Copy link
Author

kwould commented Mar 23, 2023

@keithf4 thanks, yea this should be sufficient for us in the meantime

@kwould kwould closed this as completed Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UNCONFIRMED Initial state. Need's triaged
Projects
None yet
Development

No branches or pull requests

2 participants