diff --git a/postgresql/templates/monitoring/prometheus/exporter-configmap-etc.yaml b/postgresql/templates/monitoring/prometheus/exporter-configmap-etc.yaml new file mode 100644 index 000000000..608f4fbae --- /dev/null +++ b/postgresql/templates/monitoring/prometheus/exporter-configmap-etc.yaml @@ -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 }} \ No newline at end of file diff --git a/postgresql/templates/monitoring/prometheus/exporter-deployment.yaml b/postgresql/templates/monitoring/prometheus/exporter-deployment.yaml index ce82f258a..84f2da184 100644 --- a/postgresql/templates/monitoring/prometheus/exporter-deployment.yaml +++ b/postgresql/templates/monitoring/prometheus/exporter-deployment.yaml @@ -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 }} diff --git a/postgresql/values.yaml b/postgresql/values.yaml index bfb560040..681676afa 100644 --- a/postgresql/values.yaml +++ b/postgresql/values.yaml @@ -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