|
| 1 | +{{- if .Values.cluster.monitoring.instrumentation.pgStatStatements }} |
| 2 | +apiVersion: v1 |
| 3 | +kind: ConfigMap |
| 4 | +metadata: |
| 5 | + name: {{ include "cluster.fullname" . }}-monitoring-pg-stat-statements |
| 6 | + namespace: {{ include "cluster.namespace" . }} |
| 7 | + labels: |
| 8 | + cnpg.io/reload: "" |
| 9 | + {{- include "cluster.labels" . | nindent 4 }} |
| 10 | +data: |
| 11 | + custom-queries: | |
| 12 | + pg_stat_statements: |
| 13 | + query: | |
| 14 | + SELECT d.datname |
| 15 | + , sum(s.calls) AS calls |
| 16 | + , sum(s.total_exec_time) / 1000 AS total_exec_time_seconds |
| 17 | + , sum(s.rows) AS rows |
| 18 | + , sum(s.shared_blks_hit) AS shared_blks_hit |
| 19 | + , sum(s.shared_blks_read) AS shared_blks_read |
| 20 | + , sum(s.blk_read_time) / 1000 AS blk_read_time_seconds |
| 21 | + , sum(s.blk_write_time) / 1000 AS blk_write_time_seconds |
| 22 | + FROM pg_stat_statements s |
| 23 | + JOIN pg_database d ON s.dbid = d.oid |
| 24 | + GROUP BY d.datname; |
| 25 | + target_databases: ["*"] |
| 26 | + predicate_query: "SELECT 1 FROM pg_extension WHERE extname = 'pg_stat_statements';" |
| 27 | + metrics: |
| 28 | + - datname: |
| 29 | + description: Name of the database |
| 30 | + usage: LABEL |
| 31 | + - calls: |
| 32 | + description: Total number of query executions |
| 33 | + usage: COUNTER |
| 34 | + - total_exec_time_seconds: |
| 35 | + description: Total execution time in seconds |
| 36 | + usage: COUNTER |
| 37 | + - rows: |
| 38 | + description: Total number of rows returned or affected |
| 39 | + usage: COUNTER |
| 40 | + - shared_blks_hit: |
| 41 | + description: Total number of shared block cache hits |
| 42 | + usage: COUNTER |
| 43 | + - shared_blks_read: |
| 44 | + description: Total number of shared blocks read from disk |
| 45 | + usage: COUNTER |
| 46 | + - blk_read_time_seconds: |
| 47 | + description: Total block read time in seconds |
| 48 | + usage: COUNTER |
| 49 | + - blk_write_time_seconds: |
| 50 | + description: Total block write time in seconds |
| 51 | + usage: COUNTER |
| 52 | +{{- end }} |
0 commit comments