Postgresql_exporter: Adding queries.yaml file

This change must enable postgresql-exporter to push additional metrics
(like replication_lag) which are derived using a SQL query against Postgres DB.

(Co-Author: Steven Fitzpatrick)

Change-Id: I78dc433a3782b48155ab293cb5afe90b3bc0ef1f
This commit is contained in:
Radhika Pai 2020-02-13 11:18:48 -06:00
parent f17b6de1a2
commit c884ec439b
3 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,27 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{- if and .Values.manifests.monitoring.prometheus.configmap_etc .Values.monitoring.prometheus.enabled }}
{{- $envAll := . }}
---
apiVersion: v1
kind: Secret
metadata:
name: postgresql-exporter-etc
type: Opaque
data:
{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.exporter.queries "key" "queries.yaml" "format" "Secret") | indent 2 }}
{{- end }}

View File

@ -47,6 +47,8 @@ spec:
{{ tuple $envAll "prometheus_postgresql_exporter" | include "helm-toolkit.snippets.image" | indent 10 }}
{{ tuple $envAll $envAll.Values.pod.resources.prometheus_postgresql_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
{{ dict "envAll" $envAll "application" "prometheus_postgresql_exporter" "container" "postgresql_exporter" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
args:
- "--extend.query-path=/queries.yaml"
ports:
- name: metrics
containerPort: {{ tuple "prometheus_postgresql_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
@ -56,4 +58,13 @@ spec:
secretKeyRef:
name: {{ .Values.secrets.postgresql.exporter }}
key: DATA_SOURCE_NAME
volumeMounts:
- name: postgresql-exporter-etc
mountPath: /queries.yaml
subPath: queries.yaml
volumes:
- name: postgresql-exporter-etc
secret:
secretName: postgresql-exporter-etc
defaultMode: 0444
{{- end }}

View File

@ -354,6 +354,25 @@ conf:
base_path: /var/backup
days_of_backup_to_keep: 3
pg_dumpall_options: null
exporter:
queries:
pg_replication:
query: "SELECT EXTRACT(epoch FROM (now() - pg_last_xact_replay_timestamp()))::int AS lag, CASE WHEN pg_is_in_recovery() THEN 1 ELSE 0 END AS is_replica"
master: true
metrics:
- lag:
usage: "GAUGE"
description: "Replication lag behind master in seconds"
- is_replica:
usage: "GAUGE"
description: "Indicates if this host is a replica"
pg_postmaster:
query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()"
master: true
metrics:
- start_time_seconds:
usage: "GAUGE"
description: "Time at which postmaster started"
secrets:
pki:
@ -456,6 +475,7 @@ manifests:
monitoring:
prometheus:
configmap_bin: true
configmap_etc: true
deployment_exporter: true
job_user_create: true
secret_etc: true