跳转至

Prometheus Postgres Exporter

Prometheus exporter for PostgreSQL server metrics.

This chart bootstraps a prometheus postgres exporter deployment on a Kubernetes cluster using the Helm package manager.

Prerequisites

  • Kubernetes 1.16+
  • Helm 3+

Add Helm Chart Repository

helm repo add prometheus-community https://helm-charts.itboon.top/prometheus-community
helm repo update

See helm repo for command documentation.

Install Chart

helm install [RELEASE_NAME] prometheus-community/prometheus-postgres-exporter

See configuration below.

See helm install for command documentation.

Uninstall Chart

helm uninstall [RELEASE_NAME]

This removes all the Kubernetes components associated with the chart and deletes the release.

See helm uninstall for command documentation.

Upgrading

To 4.6.0

This release adds functionality to template the variables inside config.datasource by means of allowing the tpl function in the resources that make use of it. This functionality is useful when you want to do sub-charting (e.g. in a postgres chart) and you want to avoid the duplication of variables inside config.datasource.

Compared to the previous release (4.5.0) the only thing that changed is the fact that you can no longer leave the config.datasource.host variable blank. Leaving it blank could cause errors with the tpl function. However, the default value was changed to '' so this error is not expected to happen.

To 4.0.0

This release removes the pg_database query from config.queries as it has been converted to a built-in collector in postgres_exporter v0.11.0. Any customizations to the removed query are now rendered useless and thus should be removed.

To 3.0.0

This release introduces changes to accommodate Postgres 13 or newer versions by default. Older Postgres instances have now to overwrite the pg_stat_statements query of config.queries with following selection:

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'
  AND queryid IS NOT NULL `

To 2.0.0

The primary change in 2.0.0 is the Chart API from v1 to v2. This now requires Helm3. Backwards compatibility is not guaranteed unless you modify the labels used on the chart's deployments. Use the workaround below to upgrade from versions previous to 2.0.0. The following example assumes that the release name is prometheus-postgres-exporter:

kubectl patch deployment prometheus-postgres-exporter --type=json -p='[{"op": "remove", "path": "/spec/selector/matchLabels/chart"}]'

Other minor version upgrade

helm upgrade [RELEASE_NAME] [CHART] --install

See helm upgrade for command documentation.

Configuring

See Customizing the Chart Before Installing. To see all configurable options with detailed comments, visit the chart's values.yaml, or run these configuration commands:

helm show values prometheus-community/prometheus-postgres-exporter