-
Notifications
You must be signed in to change notification settings - Fork 769
Add pg_database collector #613
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
Conversation
Converts the pg_database metrics from queries.yaml to a built in collector. This is enabled by default because it is not likely to be a performance problem and likely very useful data. Signed-off-by: Joe Adams <[email protected]>
cmd/postgres_exporter/server.go
Outdated
@@ -128,6 +131,17 @@ func (s *Server) Scrape(ch chan<- prometheus.Metric, disableSettingsMetrics bool | |||
err = fmt.Errorf("queryNamespaceMappings returned %d errors", len(errMap)) | |||
} | |||
|
|||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in a block to not reset the err var that gets set above. I don't want to return early because I don't think the errors are fatal, just informational.
Signed-off-by: Joe Adams <[email protected]>
Uses node_exporter style collector registration Signed-off-by: Joe Adams <[email protected]>
Signed-off-by: Joe Adams <[email protected]>
@SuperQ Setting up the node_exporter style collector registration required a lot more code changes so this PR got a lot larger. I had to copy a lot of the node exporter functions. This will be a much better strategy moving forward however. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
NOTE: pg_stat_bgwriter counter metrics had the `_total` suffix added #556 * [CHANGE] refactor pg_stat_bgwriter metrics into standalone collector #556 * [FEATURE] Add pg_database collector #613 * [ENHANCEMENT] Add pg_database_size_bytes metric #613 * [BUGFIX] Avoid parsing error from bogus Azure Flexible Server custom GUC #587 * [BUGFIX] Fix pg_stat_archiver error in 9.4 and earlier. #599 * [BUGFIX] Sanitize setting values because of Aurora irregularity #620 Signed-off-by: SuperQ <[email protected]>
* Update build * Update to Go 1.18. * Update minimum Go version to 1.17. * Update Go modules for 1.17 format. * Bump Go modules * Enable dependabot. * Update Prometheus common files. * Fixup yamllint. Signed-off-by: SuperQ <[email protected]> * Update common Prometheus files Signed-off-by: prombot <[email protected]> * Update common Prometheus files (prometheus-community#650) Signed-off-by: prombot <[email protected]> * Update common Prometheus files Signed-off-by: prombot <[email protected]> * Update readme to include Postgres 14 support It looks like postgres 14.1 was added to CI here: prometheus-community@fcb2535 See also: prometheus-community#651 (comment) Signed-off-by: Austin Godber <[email protected]> * Bump github.com/prometheus/common from 0.34.0 to 0.35.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.34.0 to 0.35.0. - [Release notes](https://github.com/prometheus/common/releases) - [Commits](prometheus/common@v0.34.0...v0.35.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Release v0.11.0 NOTE: pg_stat_bgwriter counter metrics had the `_total` suffix added prometheus-community#556 * [CHANGE] refactor pg_stat_bgwriter metrics into standalone collector prometheus-community#556 * [FEATURE] Add pg_database collector prometheus-community#613 * [ENHANCEMENT] Add pg_database_size_bytes metric prometheus-community#613 * [BUGFIX] Avoid parsing error from bogus Azure Flexible Server custom GUC prometheus-community#587 * [BUGFIX] Fix pg_stat_archiver error in 9.4 and earlier. prometheus-community#599 * [BUGFIX] Sanitize setting values because of Aurora irregularity prometheus-community#620 Signed-off-by: SuperQ <[email protected]> * fix for exporter issue 633 fix for exporter issue 633: prometheus-community#633 "Scan error on column index 2, name \"checkpoint_write_time\": converting driver.Value type float64 (\"6.594096e+06\") to a int: invalid syntax prometheus-community#633" Signed-off-by: bravosierrasierra <[email protected]> * Fix checkpoint_sync_time value type Error: sql: Scan error on column index 3, name \"checkpoint_sync_time\": converting driver.Value type float64 (\"1.876469e+06\") to a int: invalid syntax See also: prometheus-community#633 prometheus-community#666 Signed-off-by: Nicolas Rodriguez <[email protected]> * Release 0.11.1 * [BUGFIX] Fix checkpoint_write_time value type prometheus-community#666 * [BUGFIX] Fix checkpoint_sync_time value type prometheus-community#667 Signed-off-by: SuperQ <[email protected]> * PMM-10820 missing metric restore * PMM-10820 missing metric drop * PMM-10820 merge fix * PMM-10820 PR review fix Signed-off-by: SuperQ <[email protected]> Signed-off-by: prombot <[email protected]> Signed-off-by: Austin Godber <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: bravosierrasierra <[email protected]> Signed-off-by: Nicolas Rodriguez <[email protected]> Co-authored-by: SuperQ <[email protected]> Co-authored-by: prombot <[email protected]> Co-authored-by: Austin Godber <[email protected]> Co-authored-by: Joe Adams <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: bravosierrasierra <[email protected]> Co-authored-by: Nicolas Rodriguez <[email protected]>
After the merge of prometheus-community/postgres_exporter#613, `postgres-exporter` installed by recent versions of the prometheus-postgres-exporter Helm chart is throwing 500 errors like: ``` HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 X-Content-Type-Options: nosniff Date: Tue, 29 Nov 2022 11:08:41 GMT Content-Length: 1418 An error has occurred while serving metrics: 4 error(s) occurred: * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template0" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.225283e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"postgres" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template1" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"default" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values ``` So we're removing the YAML query to avoid such conflict. Signed-off-by: Ahmad Sherif <[email protected]>
After the merge of prometheus-community/postgres_exporter#613, `postgres-exporter` installed by recent versions of the prometheus-postgres-exporter Helm chart is throwing 500 errors like: ``` HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 X-Content-Type-Options: nosniff Date: Tue, 29 Nov 2022 11:08:41 GMT Content-Length: 1418 An error has occurred while serving metrics: 4 error(s) occurred: * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template0" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.225283e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"postgres" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template1" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"default" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values ``` So we're removing the YAML query to avoid such conflict. Signed-off-by: Ahmad Sherif <[email protected]>
* [postgres-exporter] Remove pg_database query After the merge of prometheus-community/postgres_exporter#613, `postgres-exporter` installed by recent versions of the prometheus-postgres-exporter Helm chart is throwing 500 errors like: ``` HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 X-Content-Type-Options: nosniff Date: Tue, 29 Nov 2022 11:08:41 GMT Content-Length: 1418 An error has occurred while serving metrics: 4 error(s) occurred: * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template0" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.225283e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"postgres" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template1" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"default" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values ``` So we're removing the YAML query to avoid such conflict. Signed-off-by: Ahmad Sherif <[email protected]> * [prometheus-postgres-exporter] Bump version to 3.3.1 Signed-off-by: Ahmad Sherif <[email protected]> * [prometheus-postgres-exporter] Bump version to 4.0.0 Signed-off-by: Ahmad Sherif <[email protected]> * Add upgrading notes to README.md Signed-off-by: Ahmad Sherif <[email protected]> Signed-off-by: Ahmad Sherif <[email protected]> Co-authored-by: MH <[email protected]>
…ommunity#2752) * [postgres-exporter] Remove pg_database query After the merge of prometheus-community/postgres_exporter#613, `postgres-exporter` installed by recent versions of the prometheus-postgres-exporter Helm chart is throwing 500 errors like: ``` HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 X-Content-Type-Options: nosniff Date: Tue, 29 Nov 2022 11:08:41 GMT Content-Length: 1418 An error has occurred while serving metrics: 4 error(s) occurred: * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template0" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.225283e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"postgres" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template1" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"default" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values ``` So we're removing the YAML query to avoid such conflict. Signed-off-by: Ahmad Sherif <[email protected]> * [prometheus-postgres-exporter] Bump version to 3.3.1 Signed-off-by: Ahmad Sherif <[email protected]> * [prometheus-postgres-exporter] Bump version to 4.0.0 Signed-off-by: Ahmad Sherif <[email protected]> * Add upgrading notes to README.md Signed-off-by: Ahmad Sherif <[email protected]> Signed-off-by: Ahmad Sherif <[email protected]> Co-authored-by: MH <[email protected]>
Add pg_database collector
NOTE: pg_stat_bgwriter counter metrics had the `_total` suffix added prometheus-community#556 * [CHANGE] refactor pg_stat_bgwriter metrics into standalone collector prometheus-community#556 * [FEATURE] Add pg_database collector prometheus-community#613 * [ENHANCEMENT] Add pg_database_size_bytes metric prometheus-community#613 * [BUGFIX] Avoid parsing error from bogus Azure Flexible Server custom GUC prometheus-community#587 * [BUGFIX] Fix pg_stat_archiver error in 9.4 and earlier. prometheus-community#599 * [BUGFIX] Sanitize setting values because of Aurora irregularity prometheus-community#620 Signed-off-by: SuperQ <[email protected]>
* Update build * Update to Go 1.18. * Update minimum Go version to 1.17. * Update Go modules for 1.17 format. * Bump Go modules * Enable dependabot. * Update Prometheus common files. * Fixup yamllint. Signed-off-by: SuperQ <[email protected]> * Update common Prometheus files Signed-off-by: prombot <[email protected]> * Update common Prometheus files (prometheus-community#650) Signed-off-by: prombot <[email protected]> * Update common Prometheus files Signed-off-by: prombot <[email protected]> * Update readme to include Postgres 14 support It looks like postgres 14.1 was added to CI here: prometheus-community@fcb2535 See also: prometheus-community#651 (comment) Signed-off-by: Austin Godber <[email protected]> * Bump github.com/prometheus/common from 0.34.0 to 0.35.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.34.0 to 0.35.0. - [Release notes](https://github.com/prometheus/common/releases) - [Commits](prometheus/common@v0.34.0...v0.35.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Release v0.11.0 NOTE: pg_stat_bgwriter counter metrics had the `_total` suffix added prometheus-community#556 * [CHANGE] refactor pg_stat_bgwriter metrics into standalone collector prometheus-community#556 * [FEATURE] Add pg_database collector prometheus-community#613 * [ENHANCEMENT] Add pg_database_size_bytes metric prometheus-community#613 * [BUGFIX] Avoid parsing error from bogus Azure Flexible Server custom GUC prometheus-community#587 * [BUGFIX] Fix pg_stat_archiver error in 9.4 and earlier. prometheus-community#599 * [BUGFIX] Sanitize setting values because of Aurora irregularity prometheus-community#620 Signed-off-by: SuperQ <[email protected]> * fix for exporter issue 633 fix for exporter issue 633: prometheus-community#633 "Scan error on column index 2, name \"checkpoint_write_time\": converting driver.Value type float64 (\"6.594096e+06\") to a int: invalid syntax prometheus-community#633" Signed-off-by: bravosierrasierra <[email protected]> * Fix checkpoint_sync_time value type Error: sql: Scan error on column index 3, name \"checkpoint_sync_time\": converting driver.Value type float64 (\"1.876469e+06\") to a int: invalid syntax See also: prometheus-community#633 prometheus-community#666 Signed-off-by: Nicolas Rodriguez <[email protected]> * Release 0.11.1 * [BUGFIX] Fix checkpoint_write_time value type prometheus-community#666 * [BUGFIX] Fix checkpoint_sync_time value type prometheus-community#667 Signed-off-by: SuperQ <[email protected]> * PMM-10820 missing metric restore * PMM-10820 missing metric drop * PMM-10820 merge fix * PMM-10820 PR review fix Signed-off-by: SuperQ <[email protected]> Signed-off-by: prombot <[email protected]> Signed-off-by: Austin Godber <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: bravosierrasierra <[email protected]> Signed-off-by: Nicolas Rodriguez <[email protected]> Co-authored-by: SuperQ <[email protected]> Co-authored-by: prombot <[email protected]> Co-authored-by: Austin Godber <[email protected]> Co-authored-by: Joe Adams <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: bravosierrasierra <[email protected]> Co-authored-by: Nicolas Rodriguez <[email protected]>
…ommunity#2752) * [postgres-exporter] Remove pg_database query After the merge of prometheus-community/postgres_exporter#613, `postgres-exporter` installed by recent versions of the prometheus-postgres-exporter Helm chart is throwing 500 errors like: ``` HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 X-Content-Type-Options: nosniff Date: Tue, 29 Nov 2022 11:08:41 GMT Content-Length: 1418 An error has occurred while serving metrics: 4 error(s) occurred: * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template0" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.225283e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"postgres" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"template1" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values * collected metric "pg_database_size_bytes" { label:<name:"datname" value:"default" > label:<name:"server" value:"10.188.0.2:5432" > gauge:<value:8.373103e+06 > } was collected before with the same name and label values ``` So we're removing the YAML query to avoid such conflict. Signed-off-by: Ahmad Sherif <[email protected]> * [prometheus-postgres-exporter] Bump version to 3.3.1 Signed-off-by: Ahmad Sherif <[email protected]> * [prometheus-postgres-exporter] Bump version to 4.0.0 Signed-off-by: Ahmad Sherif <[email protected]> * Add upgrading notes to README.md Signed-off-by: Ahmad Sherif <[email protected]> Signed-off-by: Ahmad Sherif <[email protected]> Co-authored-by: MH <[email protected]>
Converts the pg_database metrics from queries.yaml to a built in collector. This is enabled by default because it is not likely to be a performance problem and likely very useful data.
Signed-off-by: Joe Adams [email protected]