prometheus-postgres-exporter
by KubeGems
A Helm chart for prometheus postgres-exporter
About this chart
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://prometheus-community.github.io/helm-charts
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 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
Deploy prometheus-postgres-exporter with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has prometheus-postgres-exporter on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartprometheus-postgres-exporter is pinned at v3.0.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply