From badaf9647e57d583f22e48cae891dd95365a3d70 Mon Sep 17 00:00:00 2001 From: Olivier Tassetti <41112410+otassetti-talend@users.noreply.github.com> Date: Thu, 2 Dec 2021 11:26:57 +0100 Subject: [PATCH] [prometheus-postgres-exporter] Add support for queries in external configmap (#1545) * Add support for queries in external configmap Signed-off-by: Olivier Tassetti * Add support for queries in external configmap Signed-off-by: Olivier Tassetti * Set value as false by default Signed-off-by: Olivier Tassetti * Bump version to 2.4.0 since new functionality Signed-off-by: Olivier Tassetti * fix linting trailing space Signed-off-by: Olivier Tassetti --- charts/prometheus-postgres-exporter/Chart.yaml | 2 +- charts/prometheus-postgres-exporter/templates/configmap.yaml | 4 +++- charts/prometheus-postgres-exporter/templates/deployment.yaml | 4 ++++ charts/prometheus-postgres-exporter/values.yaml | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/charts/prometheus-postgres-exporter/Chart.yaml b/charts/prometheus-postgres-exporter/Chart.yaml index a30867bbf5cc..80530ba4c1cc 100644 --- a/charts/prometheus-postgres-exporter/Chart.yaml +++ b/charts/prometheus-postgres-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: "0.10.0" description: A Helm chart for prometheus postgres-exporter name: prometheus-postgres-exporter -version: 2.3.7 +version: 2.4.0 home: https://github.com/prometheus-community/postgres_exporter sources: - https://github.com/prometheus-community/postgres_exporter diff --git a/charts/prometheus-postgres-exporter/templates/configmap.yaml b/charts/prometheus-postgres-exporter/templates/configmap.yaml index 52467b6faf87..91b47e2aca1d 100644 --- a/charts/prometheus-postgres-exporter/templates/configmap.yaml +++ b/charts/prometheus-postgres-exporter/templates/configmap.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.config.externalQueries.enabled }} apiVersion: v1 kind: ConfigMap metadata: @@ -9,4 +10,5 @@ metadata: heritage: {{ .Release.Service }} data: config.yaml: | -{{ printf .Values.config.queries | indent 4 }} \ No newline at end of file +{{ printf .Values.config.queries | indent 4 }} +{{- end }} diff --git a/charts/prometheus-postgres-exporter/templates/deployment.yaml b/charts/prometheus-postgres-exporter/templates/deployment.yaml index 602790148ff0..df5b3cb2a1df 100644 --- a/charts/prometheus-postgres-exporter/templates/deployment.yaml +++ b/charts/prometheus-postgres-exporter/templates/deployment.yaml @@ -139,7 +139,11 @@ spec: volumes: - configMap: defaultMode: 420 + {{- if not .Values.config.externalQueries.enabled }} name: {{ template "prometheus-postgres-exporter.fullname" . }} + {{- else }} + name: {{ .Values.config.externalQueries.configmap }} + {{- end }} name: queries {{- with .Values.extraVolumes }} {{ toYaml . | indent 6 }} diff --git a/charts/prometheus-postgres-exporter/values.yaml b/charts/prometheus-postgres-exporter/values.yaml index ef0237927bbb..f930785936cd 100644 --- a/charts/prometheus-postgres-exporter/values.yaml +++ b/charts/prometheus-postgres-exporter/values.yaml @@ -119,6 +119,10 @@ config: constantLabels: {} # possible values debug, info, warn, error, fatal logLevel: "" + # Enable queries from an external configmap, enable it will disable inline queries below + externalQueries: + enabled: false + configmap: postgresql-common-exporter-queries # These are the default queries that the exporter will run, extracted from: https://github.com/prometheus-community/postgres_exporter/blob/master/queries.yaml queries: |- pg_replication: