From 3ecfd46549fa19006dd2399f79349cdf5a653ec8 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Wed, 26 Feb 2020 00:49:30 +1100 Subject: [PATCH 1/4] Switch to debian baseimage for docker (#376) --- Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 86128d41..7d17c926 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 2/4] ARM64 platform (#386) --- magefile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/magefile.go b/magefile.go index b3e0992f..eedd529d 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 3/4] 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 a81bcd9b..8864b88c 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. From e2df41f43effdfbb4544b3efb70350380ad895fe Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 9 Apr 2020 11:16:22 -0400 Subject: [PATCH 4/4] Fix queries for awsrds (#370) * excluding rolname 'rdsadmin' in pg_stat_statements * notes on using postgres-exporter with AWS:RDS --- README-RDS.md | 38 ++++++++++++++++++++++++++++++++++++++ queries.yaml | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 README-RDS.md diff --git a/README-RDS.md b/README-RDS.md new file mode 100644 index 00000000..cfead357 --- /dev/null +++ b/README-RDS.md @@ -0,0 +1,38 @@ +# Using Postgres-Exporter with AWS:RDS + +### When using postgres-exporter with Amazon Web Services' RDS, the + rolname "rdsadmin" and datname "rdsadmin" must be excluded. + +I had success running docker container 'wrouesnel/postgres_exporter:latest' +with queries.yaml as the PG_EXPORTER_EXTEND_QUERY_PATH. errors +mentioned in issue#335 appeared and I had to modify the +'pg_stat_statements' query with the following: +`WHERE t2.rolname != 'rdsadmin'` + +Running postgres-exporter in a container like so: + ``` + DBNAME='postgres' + PGUSER='postgres' + PGPASS='psqlpasswd123' + PGHOST='name.blahblah.us-east-1.rds.amazonaws.com' + docker run --rm --detach \ + --name "postgresql_exporter_rds" \ + --publish 9187:9187 \ + --volume=/etc/prometheus/postgresql-exporter/queries.yaml:/var/lib/postgresql/queries.yaml \ + -e DATA_SOURCE_NAME="postgresql://${PGUSER}:${PGPASS}@${PGHOST}:5432/${DBNAME}?sslmode=disable" \ + -e PG_EXPORTER_EXCLUDE_DATABASES=rdsadmin \ + -e PG_EXPORTER_DISABLE_DEFAULT_METRICS=true \ + -e PG_EXPORTER_DISABLE_SETTINGS_METRICS=true \ + -e PG_EXPORTER_EXTEND_QUERY_PATH='/var/lib/postgresql/queries.yaml' \ + wrouesnel/postgres_exporter + ``` + +### Expected changes to RDS: ++ see stackoverflow notes + (https://stackoverflow.com/questions/43926499/amazon-postgres-rds-pg-stat-statements-not-loaded#43931885) ++ you must also use a specific RDS parameter_group that includes the following: + ``` + shared_preload_libraries = "pg_stat_statements,pg_hint_plan" + ``` ++ lastly, you must reboot the RDS instance. + diff --git a/queries.yaml b/queries.yaml index 76a91245..18abd65b 100644 --- a/queries.yaml +++ b/queries.yaml @@ -134,7 +134,7 @@ pg_database: description: "Disk space used by the database" pg_stat_statements: - query: "SELECT t2.rolname, t3.datname, queryid, calls, total_time / 1000 as total_time_seconds, min_time / 1000 as min_time_seconds, max_time / 1000 as max_time_seconds, mean_time / 1000 as mean_time_seconds, stddev_time / 1000 as stddev_time_seconds, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written, temp_blks_read, temp_blks_written, blk_read_time / 1000 as blk_read_time_seconds, blk_write_time / 1000 as blk_write_time_seconds FROM pg_stat_statements t1 join pg_roles t2 on (t1.userid=t2.oid) join pg_database t3 on (t1.dbid=t3.oid)" + query: "SELECT t2.rolname, t3.datname, queryid, calls, total_time / 1000 as total_time_seconds, min_time / 1000 as min_time_seconds, max_time / 1000 as max_time_seconds, mean_time / 1000 as mean_time_seconds, stddev_time / 1000 as stddev_time_seconds, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written, temp_blks_read, temp_blks_written, blk_read_time / 1000 as blk_read_time_seconds, blk_write_time / 1000 as blk_write_time_seconds FROM pg_stat_statements t1 JOIN pg_roles t2 ON (t1.userid=t2.oid) JOIN pg_database t3 ON (t1.dbid=t3.oid) WHERE t2.rolname != 'rdsadmin'" master: true metrics: - rolname: