Skip to content

Commit 994846e

Browse files
authored
Update metrics integration to use pgMonitor v4.5
This aligns the Crunchy Postgres Exporter integration with pgMonitor 4.5, bringing in new metrics that are collected for various parts of the Postgres cluster. This incorporates newer dashboards that are available for monitoring, including stats around query runtimes and pgBackRest. This also bumps versions of Prometheus and Grafana to 2.26.0 and 7.4.5 respectively, and drops support for Postgres 9.5 metrics. Issue: [ch11157] Issue: [ch11156]
1 parent 3df8bba commit 994846e

File tree

9 files changed

+65
-66
lines changed

9 files changed

+65
-66
lines changed

bin/crunchy-postgres-exporter/start.sh

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ POSTGRES_EXPORTER_PIDFILE=/tmp/postgres_exporter.pid
2222
CONFIG_DIR='/opt/cpm/conf'
2323
QUERIES=(
2424
queries_backrest
25-
queries_common
25+
queries_global
2626
queries_per_db
2727
queries_nodemx
28+
queries_pg_stat_statements_reset
2829
)
2930

3031
function trap_sigterm() {
@@ -118,103 +119,87 @@ else
118119
then
119120
cat ${CONFIG_DIR?}/${query?}.yml >> /tmp/queries.yml
120121
else
121-
echo_err "Custom Query file ${query?}.yml does not exist (it should).."
122+
echo_err "Query file ${query?}.yml does not exist (it should).."
122123
exit 1
123124
fi
124125
done
125126

126127
VERSION=$(PGPASSWORD="${EXPORTER_PG_PASSWORD}" ${PG_DIR?}/bin/psql -h "${EXPORTER_PG_HOST}" -p "${EXPORTER_PG_PORT}" -U "${EXPORTER_PG_USER}" -qtAX -c "SELECT current_setting('server_version_num')" "${EXPORTER_PG_DATABASE}")
127-
if (( ${VERSION?} >= 90500 )) && (( ${VERSION?} < 90600 ))
128+
if (( ${VERSION?} >= 90600 )) && (( ${VERSION?} < 100000 ))
128129
then
129-
if [[ -f ${CONFIG_DIR?}/queries_pg95.yml ]]
130+
if [[ -f ${CONFIG_DIR?}/pg96/queries_general.yml ]]
130131
then
131-
cat ${CONFIG_DIR?}/queries_pg95.yml >> /tmp/queries.yml
132+
cat ${CONFIG_DIR?}/pg96/queries_general.yml >> /tmp/queries.yml
132133
else
133-
echo_err "Custom Query file queries_pg95.yml does not exist (it should).."
134-
fi
135-
if [[ -f ${CONFIG_DIR?}/queries_pg_stat_statements_pg95.yml ]]
136-
then
137-
cat ${CONFIG_DIR?}/queries_pg_stat_statements_pg95.yml >> /tmp/queries.yml
138-
else
139-
echo_warn "Custom Query file queries_pg_stat_statements_pg95.yml not loaded."
140-
fi
141-
elif (( ${VERSION?} >= 90600 )) && (( ${VERSION?} < 100000 ))
142-
then
143-
if [[ -f ${CONFIG_DIR?}/queries_pg96.yml ]]
144-
then
145-
cat ${CONFIG_DIR?}/queries_pg96.yml >> /tmp/queries.yml
146-
else
147-
echo_err "Custom Query file queries_pg96.yml does not exist (it should).."
148-
fi
149-
if [[ -f ${CONFIG_DIR?}/queries_pg_stat_statements_pg96.yml ]]
150-
then
151-
cat ${CONFIG_DIR?}/queries_pg_stat_statements_pg96.yml >> /tmp/queries.yml
152-
else
153-
echo_warn "Custom Query file queries_pg_stat_statements_pg96.yml not loaded."
134+
echo_err "Query file queries_general.yml does not exist (it should).."
154135
fi
155136
elif (( ${VERSION?} >= 100000 )) && (( ${VERSION?} < 110000 ))
156137
then
157-
if [[ -f ${CONFIG_DIR?}/queries_pg10.yml ]]
138+
if [[ -f ${CONFIG_DIR?}/pg10/queries_general.yml ]]
158139
then
159-
cat ${CONFIG_DIR?}/queries_pg10.yml >> /tmp/queries.yml
140+
cat ${CONFIG_DIR?}/pg10/queries_general.yml >> /tmp/queries.yml
160141
else
161-
echo_err "Custom Query file queries_pg10.yml does not exist (it should).."
142+
echo_err "Query file queries_general.yml does not exist (it should).."
162143
fi
163-
if [[ -f ${CONFIG_DIR?}/queries_pg_stat_statements_pg10.yml ]]
144+
if [[ -f ${CONFIG_DIR?}/pg10/queries_pg_stat_statements.yml ]]
164145
then
165-
cat ${CONFIG_DIR?}/queries_pg_stat_statements_pg10.yml >> /tmp/queries.yml
146+
cat ${CONFIG_DIR?}/pg10/queries_pg_stat_statements.yml >> /tmp/queries.yml
166147
else
167-
echo_warn "Custom Query file queries_pg_stat_statements_pg10.yml not loaded."
148+
echo_warn "Query file queries_pg_stat_statements.yml not loaded."
168149
fi
169150
elif (( ${VERSION?} >= 110000 )) && (( ${VERSION?} < 120000 ))
170151
then
171-
if [[ -f ${CONFIG_DIR?}/queries_pg11.yml ]]
152+
if [[ -f ${CONFIG_DIR?}/pg11/queries_general.yml ]]
172153
then
173-
cat ${CONFIG_DIR?}/queries_pg11.yml >> /tmp/queries.yml
154+
cat ${CONFIG_DIR?}/pg11/queries_general.yml >> /tmp/queries.yml
174155
else
175-
echo_err "Custom Query file queries_pg11.yml does not exist (it should).."
156+
echo_err "Query file queries_general.yml does not exist (it should).."
176157
fi
177-
if [[ -f ${CONFIG_DIR?}/queries_pg_stat_statements_pg11.yml ]]
158+
if [[ -f ${CONFIG_DIR?}/pg11/queries_pg_stat_statements.yml ]]
178159
then
179-
cat ${CONFIG_DIR?}/queries_pg_stat_statements_pg11.yml >> /tmp/queries.yml
160+
cat ${CONFIG_DIR?}/pg11/queries_pg_stat_statements.yml >> /tmp/queries.yml
180161
else
181-
echo_warn "Custom Query file queries_pg_stat_statements_pg11.yml not loaded."
162+
echo_warn "Query file queries_pg_stat_statements.yml not loaded."
182163
fi
183164
elif (( ${VERSION?} >= 120000 )) && (( ${VERSION?} < 130000 ))
184165
then
185-
if [[ -f ${CONFIG_DIR?}/queries_pg12.yml ]]
166+
if [[ -f ${CONFIG_DIR?}/pg12/queries_general.yml ]]
186167
then
187-
cat ${CONFIG_DIR?}/queries_pg12.yml >> /tmp/queries.yml
168+
cat ${CONFIG_DIR?}/pg12/queries_general.yml >> /tmp/queries.yml
188169
else
189-
echo_err "Custom Query file queries_pg12.yml does not exist (it should).."
170+
echo_err "Query file queries_general.yml does not exist (it should).."
190171
fi
191-
if [[ -f ${CONFIG_DIR?}/queries_pg_stat_statements_pg12.yml ]]
172+
if [[ -f ${CONFIG_DIR?}/pg12/queries_pg_stat_statements.yml ]]
192173
then
193-
cat ${CONFIG_DIR?}/queries_pg_stat_statements_pg12.yml >> /tmp/queries.yml
174+
cat ${CONFIG_DIR?}/pg12/queries_pg_stat_statements.yml >> /tmp/queries.yml
194175
else
195-
echo_warn "Custom Query file queries_pg_stat_statements_pg12.yml not loaded."
176+
echo_warn "Query file queries_pg_stat_statements.yml not loaded."
196177
fi
197-
elif (( ${VERSION?} >= 130000 ))
178+
elif (( ${VERSION?} >= 130000 ))
198179
then
199-
if [[ -f ${CONFIG_DIR?}/queries_pg13.yml ]]
180+
if [[ -f ${CONFIG_DIR?}/pg13/queries_general.yml ]]
200181
then
201-
cat ${CONFIG_DIR?}/queries_pg13.yml >> /tmp/queries.yml
182+
cat ${CONFIG_DIR?}/pg13/queries_general.yml >> /tmp/queries.yml
202183
else
203-
echo_err "Custom Query file queries_pg13.yml does not exist (it should).."
184+
echo_err "Query file queries_general.yml does not exist (it should).."
204185
fi
205-
if [[ -f ${CONFIG_DIR?}/queries_pg_stat_statements_pg13.yml ]]
186+
if [[ -f ${CONFIG_DIR?}/pg13/queries_pg_stat_statements.yml ]]
206187
then
207-
cat ${CONFIG_DIR?}/queries_pg_stat_statements_pg13.yml >> /tmp/queries.yml
188+
cat ${CONFIG_DIR?}/pg13/queries_pg_stat_statements.yml >> /tmp/queries.yml
208189
else
209-
echo_warn "Custom Query file queries_pg_stat_statements_pg13.yml not loaded."
190+
echo_warn "Query file queries_pg_stat_statements.yml not loaded."
210191
fi
211192
else
212193
echo_err "Unknown or unsupported version of PostgreSQL. Exiting.."
213194
exit 1
214195
fi
215196
fi
216197

217-
sed -i -e "s/#PGBACKREST_INFO_THROTTLE_MINUTES#/${PGBACKREST_INFO_THROTTLE_MINUTES:-10}/g" -e "s/#PG_STAT_STATEMENTS_LIMIT#/${PG_STAT_STATEMENTS_LIMIT:-20}/g" /tmp/queries.yml
198+
sed -i \
199+
-e "s/#PGBACKREST_INFO_THROTTLE_MINUTES#/${PGBACKREST_INFO_THROTTLE_MINUTES:-10}/g" \
200+
-e "s/#PG_STAT_STATEMENTS_LIMIT#/${PG_STAT_STATEMENTS_LIMIT:-20}/g" \
201+
-e "s/#PG_STAT_STATEMENTS_THROTTLE_MINUTES#/${PG_STAT_STATEMENTS_THROTTLE_MINUTES:--1}/g" \
202+
/tmp/queries.yml
218203

219204
PG_OPTIONS="--extend.query-path=${QUERY_DIR?}/queries.yml --web.listen-address=:${POSTGRES_EXPORTER_PORT}"
220205

bin/get-pgmonitor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515

1616
echo "Getting pgMonitor..."
17-
PGMONITOR_COMMIT='v4.4'
17+
PGMONITOR_COMMIT='v4.5-RC2'
1818

1919
# pgMonitor Setup
2020
if [[ -d ${PGOROOT?}/tools/pgmonitor ]]

build/crunchy-postgres-exporter/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ fi
4545
RUN mkdir -p /opt/cpm/bin /opt/cpm/conf
4646

4747
ADD postgres_exporter.tar.gz /opt/cpm/bin
48-
ADD tools/pgmonitor/exporter/postgres /opt/cpm/conf
48+
ADD tools/pgmonitor/postgres_exporter/common /opt/cpm/conf
49+
ADD tools/pgmonitor/postgres_exporter/linux /opt/cpm/conf
4950
ADD bin/crunchy-postgres-exporter /opt/cpm/bin
5051
ADD bin/common /opt/cpm/bin
5152

docs/content/installation/metrics/metrics-configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ and tag as needed to use the RedHat certified containers:
108108
| `alertmanager_image_tag` | v0.21.0 | **Required** | Configures the image tag to use for the Alertmanager container. |
109109
| `grafana_image_prefix` | grafana | **Required** | Configures the image prefix to use for the Grafana container.|
110110
| `grafana_image_name` | grafana | **Required** | Configures the image name to use for the Grafana container. |
111-
| `grafana_image_tag` | 6.7.5 | **Required** | Configures the image tag to use for the Grafana container. |
111+
| `grafana_image_tag` | 7.4.5 | **Required** | Configures the image tag to use for the Grafana container. |
112112
| `prometheus_image_prefix` | prom | **Required** | Configures the image prefix to use for the Prometheus container. |
113113
| `prometheus_image_name` | promtheus | **Required** | Configures the image name to use for the Prometheus container. |
114-
| `prometheus_image_tag` | v2.24.0 | **Required** | Configures the image tag to use for the Prometheus container. |
114+
| `prometheus_image_tag` | v2.26.0 | **Required** | Configures the image tag to use for the Prometheus container. |
115115

116116
Additionally, these same settings can be utilized as needed to support custom image names,
117117
tags, and additional container registries.

installers/metrics/ansible/roles/pgo-metrics/defaults/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ delete_metrics_namespace: "false"
99
metrics_namespace: "pgo"
1010
metrics_image_pull_secret: ""
1111
metrics_image_pull_secret_manifest: ""
12-
pgmonitor_version: "v4.4"
12+
pgmonitor_version: "v4.5-RC2"
1313

1414
alertmanager_configmap: "alertmanager-config"
1515
alertmanager_rules_configmap: "alertmanager-rules-config"
@@ -29,7 +29,7 @@ grafana_admin_password: ""
2929
grafana_install: "true"
3030
grafana_image_prefix: "grafana"
3131
grafana_image_name: "grafana"
32-
grafana_image_tag: "6.7.5"
32+
grafana_image_tag: "7.4.5"
3333
grafana_port: "3000"
3434
grafana_service_name: "crunchy-grafana"
3535
grafana_service_type: "ClusterIP"
@@ -45,7 +45,7 @@ prometheus_custom_config: ""
4545
prometheus_install: "true"
4646
prometheus_image_prefix: "prom"
4747
prometheus_image_name: "prometheus"
48-
prometheus_image_tag: "v2.24.0"
48+
prometheus_image_tag: "v2.26.0"
4949
prometheus_port: "9090"
5050
prometheus_service_name: "crunchy-prometheus"
5151
prometheus_service_type: "ClusterIP"

installers/metrics/ansible/roles/pgo-metrics/tasks/alertmanager.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,22 @@
1414
state: "directory"
1515
mode: "0700"
1616

17-
- name: Set pgmonitor Prometheus Directory Fact
17+
- name: Set pgmonitor Alertmanger Directory Fact
1818
set_fact:
19-
pgmonitor_prometheus_dir: "{{ pgmonitor_dir }}/prometheus"
19+
pgmonitor_alertmanager_dir: "{{ pgmonitor_dir }}/alertmanager/common"
2020

2121
- name: Copy Alertmanger Config to Output Directory
22-
command: "cp {{ pgmonitor_prometheus_dir }}/{{ item.src }} {{ alertmanager_output_dir }}/{{ item.dst }}"
22+
command: "cp {{ pgmonitor_alertmanager_dir }}/{{ item.src }} {{ alertmanager_output_dir }}/{{ item.dst }}"
2323
loop:
2424
- { src: 'crunchy-alertmanager.yml', dst: 'alertmanager.yml'}
25+
26+
- name: Set pgmonitor Prometheus Directory Fact
27+
set_fact:
28+
pgmonitor_prometheus_dir: "{{ pgmonitor_dir }}/prometheus/containers"
29+
30+
- name: Copy Prometheus-Alertmanger Config to Output Directory
31+
command: "cp {{ pgmonitor_prometheus_dir }}/{{ item.src }} {{ alertmanager_output_dir }}/{{ item.dst }}"
32+
loop:
2533
- { src: 'alert-rules.d/crunchy-alert-rules-pg.yml.containers.example', dst: 'crunchy-alert-rules-pg.yml'}
2634

2735
- name: Create Alertmanager Config ConfigMap

installers/metrics/ansible/roles/pgo-metrics/tasks/grafana.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@
5050
set_fact:
5151
pgmonitor_grafana_dir: "{{ pgmonitor_dir }}/grafana"
5252

53-
- name: Copy Grafana Config to Output Directory
54-
command: "cp {{ pgmonitor_grafana_dir }}/{{ item }} {{ grafana_output_dir }}"
53+
- name: Copy Grafana data source to Output Directory
54+
command: "cp {{ pgmonitor_grafana_dir }}/common/{{ item }} {{ grafana_output_dir }}"
5555
loop:
5656
- crunchy_grafana_datasource.yml
57+
58+
- name: Copy Grafana dashboards to Output Directory
59+
command: "cp {{ pgmonitor_grafana_dir }}/linux/{{ item }} {{ grafana_output_dir }}"
60+
loop:
5761
- crunchy_grafana_dashboards.yml
5862

5963
- name: Add Grafana Dashboard Configuration

installers/metrics/ansible/roles/pgo-metrics/tasks/prometheus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
- name: Set pgmonitor Prometheus Directory Fact
3737
set_fact:
38-
pgmonitor_prometheus_dir: "{{ pgmonitor_dir }}/prometheus"
38+
pgmonitor_prometheus_dir: "{{ pgmonitor_dir }}/prometheus/containers"
3939

4040
- name: Copy Prometheus Config to Output Directory
4141
command: "cp {{ pgmonitor_prometheus_dir }}/{{ item.src }} {{ prom_output_dir }}/{{ item.dst }}"

installers/metrics/ansible/roles/pgo-metrics/templates/alertmanager-deployment.json.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"args": [
4343
"--config.file=/etc/alertmanager/alertmanager.yml",
4444
"--storage.path=/alertmanager",
45-
"--log.level={{ alertmanager_log_level }}"
45+
"--log.level={{ alertmanager_log_level }}",
46+
"--cluster.advertise-address=0.0.0.0:{{ alertmanager_port }}"
4647
],
4748
"ports": [
4849
{

0 commit comments

Comments
 (0)