From 0c4425c4b3cf97f037f9155ff937913eb714cd8b Mon Sep 17 00:00:00 2001 From: rafis Date: Tue, 25 Feb 2020 14:56:18 +0300 Subject: [PATCH 1/6] Fix max connection alerts formulas (#368) --- example.alerts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example.alerts.yml b/example.alerts.yml index 1b08a437f..ff3d75a7f 100644 --- a/example.alerts.yml +++ b/example.alerts.yml @@ -3,7 +3,7 @@ groups: - name: PostgreSQL rules: - alert: PostgreSQLMaxConnectionsReached - expr: sum(pg_stat_activity_count) by (instance) > sum(pg_settings_max_connections) by (instance) + expr: sum(pg_stat_activity_count) by (instance) >= sum(pg_settings_max_connections) by (instance) - sum(pg_settings_superuser_reserved_connections) by (instance) for: 1m labels: severity: email @@ -12,7 +12,7 @@ groups: description: "{{ $labels.instance }} is exceeding the currently configured maximum Postgres connection limit (current value: {{ $value }}s). Services may be degraded - please take immediate action (you probably need to increase max_connections in the Docker image and re-deploy." - alert: PostgreSQLHighConnections - expr: sum(pg_stat_activity_count) by (instance) > sum(pg_settings_max_connections * 0.8) by (instance) + expr: sum(pg_stat_activity_count) by (instance) > (sum(pg_settings_max_connections) by (instance) - sum(pg_settings_superuser_reserved_connections) by (instance)) * 0.8 for: 10m labels: severity: email From f870f9591b9eb0a524a3b0ce109827d9992bcee5 Mon Sep 17 00:00:00 2001 From: Don Petersen Date: Tue, 25 Feb 2020 03:56:49 -0800 Subject: [PATCH 2/6] Don't ignore errors in parseUserQueries (#362) Failures in parsing the user's queries are just being swallowed, which makes troubleshooting YAML issues frustrating/impossible. I'm presuming this was not intentional, since there is error handling code in the function that calls this one, though it is unreachable as far as I can tell without this change. Co-authored-by: Will Rouesnel --- cmd/postgres_exporter/postgres_exporter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/postgres_exporter/postgres_exporter.go b/cmd/postgres_exporter/postgres_exporter.go index 1a9eaaa79..37795aacf 100644 --- a/cmd/postgres_exporter/postgres_exporter.go +++ b/cmd/postgres_exporter/postgres_exporter.go @@ -542,7 +542,7 @@ func parseUserQueries(content []byte) (map[string]intermediateMetricMap, map[str func addQueries(content []byte, pgVersion semver.Version, server *Server) error { metricMaps, newQueryOverrides, err := parseUserQueries(content) if err != nil { - return nil + return err } // Convert the loaded metric map into exporter representation partialExporterMap := makeDescMap(pgVersion, server.labels, metricMaps) From 81f9c78d61bfaed6883f0f824cc5c891fc270ea5 Mon Sep 17 00:00:00 2001 From: Daniel Binkhuysen Date: Tue, 25 Feb 2020 12:57:23 +0100 Subject: [PATCH 3/6] fix pg_database_size_bytes metric in queries.yaml (#357) Co-authored-by: Will Rouesnel --- queries.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.yaml b/queries.yaml index db2c0680b..76a91245d 100644 --- a/queries.yaml +++ b/queries.yaml @@ -122,7 +122,7 @@ pg_statio_user_tables: description: "Number of buffer hits in this table's TOAST table indexes (if any)" pg_database: - query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size FROM pg_database" + query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size_bytes FROM pg_database" master: true cache_seconds: 30 metrics: From 3ecfd46549fa19006dd2399f79349cdf5a653ec8 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Wed, 26 Feb 2020 00:49:30 +1100 Subject: [PATCH 4/6] Switch to debian baseimage for docker (#376) --- Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 86128d41a..7d17c9266 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,6 @@ -FROM debian:7.11-slim +FROM debian:10-slim RUN useradd -u 20001 postgres_exporter -FROM scratch - -COPY --from=0 /etc/passwd /etc/passwd USER postgres_exporter ARG binary From aac3b0d919e7150a21e14b9c2dd1bea6fa8dcfc1 Mon Sep 17 00:00:00 2001 From: Denis Gubanov Date: Thu, 9 Apr 2020 18:14:06 +0300 Subject: [PATCH 5/6] ARM64 platform (#386) --- magefile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/magefile.go b/magefile.go index b3e0992f8..eedd529d6 100644 --- a/magefile.go +++ b/magefile.go @@ -97,6 +97,7 @@ func (p *Platform) ReleaseBase() string { var platforms []Platform = []Platform{ {"linux", "amd64", ""}, {"linux", "386", ""}, + {"linux", "arm64", ""}, {"darwin", "amd64", ""}, {"darwin", "386", ""}, {"windows", "amd64", ".exe"}, From 77d42931d04daad4a0e9ceabb766141a4e0f6066 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Thu, 9 Apr 2020 11:14:24 -0400 Subject: [PATCH 6/6] update docs with examples of DATA_SOURCE_URI (#378) this has a minor change to the wording and a couple of examples to demonstrate the use of DATA_SOURCE_URI. Closes #113 --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a81bcd9b2..8864b88c4 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,9 @@ The following environment variables configure the exporter: URI may contain the username and password to connect with. * `DATA_SOURCE_URI` - an alternative to `DATA_SOURCE_NAME` which exclusively accepts the raw URI - without a username and password component. + an alternative to `DATA_SOURCE_NAME` which exclusively accepts the hostname + without a username and password component. For example, `my_pg_hostname` or + `my_pg_hostname?sslmode=disable`. * `DATA_SOURCE_URI_FILE` The same as above but reads the URI from a file.