Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/cluster/templates/_bootstrap.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bootstrap:
{{- else if eq .Values.type "timescaledb" }}
- CREATE EXTENSION IF NOT EXISTS timescaledb;
{{- end }}
- CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
{{- with .Values.cluster.initdb }}
{{- range .postInitApplicationSQL }}
{{- printf "- %s" . | nindent 6 }}
Expand Down
1 change: 1 addition & 0 deletions charts/cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ spec:
{{- if eq .Values.type "timescaledb" }}
- timescaledb
{{- end }}
- pg_stat_statements
{{- with .Values.cluster.postgresql.shared_preload_libraries }}
{{- toYaml . | nindent 6 }}
{{- end }}
Expand Down
52 changes: 52 additions & 0 deletions charts/cluster/templates/monitoring-pg-stat-statements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- if .Values.cluster.monitoring.instrumentation.pgStatStatements }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "cluster.fullname" . }}-monitoring-pg-stat-statements
namespace: {{ include "cluster.namespace" . }}
labels:
cnpg.io/reload: ""
{{- include "cluster.labels" . | nindent 4 }}
data:
custom-queries: |
pg_stat_statements:
query: |
SELECT d.datname
, sum(s.calls) AS calls
, sum(s.total_exec_time) / 1000 AS total_exec_time_seconds
, sum(s.rows) AS rows
, sum(s.shared_blks_hit) AS shared_blks_hit
, sum(s.shared_blks_read) AS shared_blks_read
, sum(s.blk_read_time) / 1000 AS blk_read_time_seconds
, sum(s.blk_write_time) / 1000 AS blk_write_time_seconds
FROM pg_stat_statements s
JOIN pg_database d ON s.dbid = d.oid
GROUP BY d.datname;
target_databases: ["*"]
predicate_query: "SELECT 1 FROM pg_extension WHERE extname = 'pg_stat_statements';"
metrics:
- datname:
description: Name of the database
usage: LABEL
- calls:
description: Total number of query executions
usage: COUNTER
- total_exec_time_seconds:
description: Total execution time in seconds
usage: COUNTER
- rows:
description: Total number of rows returned or affected
usage: COUNTER
- shared_blks_hit:
description: Total number of shared block cache hits
usage: COUNTER
- shared_blks_read:
description: Total number of shared blocks read from disk
usage: COUNTER
- blk_read_time_seconds:
description: Total block read time in seconds
usage: COUNTER
- blk_write_time_seconds:
description: Total block write time in seconds
usage: COUNTER
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
pg_ident:
- mymap /^(.*)@mydomain\.com$ \1
shared_preload_libraries:
- pg_stat_statements
- pgaudit
synchronous:
method: any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ cluster:
pg_ident:
- mymap /^(.*)@mydomain\.com$ \1
shared_preload_libraries:
- pg_stat_statements
- pgaudit
synchronous:
method: any
Expand Down