prometheus-community / prometheus-community/postgres_exporter
Allow to specify version constrains in the queries.yaml
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3.6k
- Forks
- 835
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 10
Description
Proposal
I'm not sure if this is a bug or the feature or just missing documentation. Please, judge.
I guess there is no question that depending on the version of PostgreSQL the statistics and even the name/number of fields in the statistics may differ. I see that even in the built-in queries this is taken into account and some queries are omitted and some have different sets of fields, depending on the version.
Looking closer at the https://github.com/prometheus-community/postgres_exporter/blob/fb316ad4ae42f8469be1745e5433cca622b98365/cmd/postgres_exporter/queries.go#L48 and around I'm under the impression that it should be possible to limit user-defined queries to certain versions of the PostgreSQL.
My poor knowledge of Golang doesn't help to figure out what is exactly there, but code block:
type UserQuery struct {
Query string `yaml:"query"`
Metrics []Mapping `yaml:"metrics"`
Master bool `yaml:"master"` // Querying only for master database
CacheSeconds uint64 `yaml:"cache_seconds"` // Number of seconds to cache the namespace result metrics for.
RunOnServer string `yaml:"runonserver"` // Querying to run on which server version
}
looks like it's possible to specify runonserver field with SemVer string that would limit the query, defined in queries.yaml to the specified version(s) of the server only.
Unfortunately, several attempts to use it seems didn't work for me.
So, depending on the current state I'd like either to request such a feature to be added or if it is already there - to be documented at least in the sample queries.yaml or, if it's there, but not working - to fix it.
Sorry for such a hectic request, but I think its type really depends on the current state of things.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the UserQuery handling in cmd/postgres_exporter/queries.go and comparing it with the sample queries.yaml configuration. Determine whether runonserver accepts and applies PostgreSQL version constraints; done means the requested behavior works for user-defined queries or its supported syntax is documented in the sample configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100