Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prometheus-postgres-exporter] Implement multiple target with /probe … #5012

2 changes: 1 addition & 1 deletion charts/prometheus-postgres-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: "v0.16.0"
description: A Helm chart for prometheus postgres-exporter
name: prometheus-postgres-exporter
version: 6.6.0
version: 6.7.0
home: https://github.com/prometheus-community/postgres_exporter
sources:
- https://github.com/prometheus-community/postgres_exporter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,52 @@ metadata:
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
{{- if .Values.serviceMonitor.multipleTargets.enabled }}
endpoints:
{{- range .Values.serviceMonitor.multipleTargets.targets }}
- path: /probe
port: {{ $.Values.service.name }}
{{- if $.Values.serviceMonitor.interval }}
interval: {{ $.Values.serviceMonitor.interval }}
{{- end }}
{{- if $.Values.serviceMonitor.timeout }}
scrapeTimeout: {{ $.Values.serviceMonitor.timeout }}
{{- end }}
{{- if $.Values.serviceMonitor.scheme }}
scheme: {{ $.Values.serviceMonitor.scheme }}
{{- end }}
{{- with $.Values.serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 6 }}
{{- end }}
metricRelabelings:
- action: replace
replacement: {{ .endpoint }}
sourceLabels: [instance]
targetLabel: instance
- action: replace
replacement: {{ .name }}
sourceLabels: [target]
targetLabel: target
{{- if $.Values.serviceMonitor.metricRelabelings -}}
{{ toYaml $.Values.serviceMonitor.metricRelabelings | nindent 8 }}
{{- end }}
{{- if $.Values.serviceMonitor.relabelings }}
relabelings: {{ toYaml $.Values.serviceMonitor.relabelings | nindent 8 }}
{{- end }}
params:
target:
- {{ .endpoint }}:{{ .port | default 5432 }}/postgres
festeveira marked this conversation as resolved.
Show resolved Hide resolved
{{- if $.Values.serviceMonitor.multipleTargets.sharedAuthModule.enabled }}
auth_module:
- {{ $.Values.serviceMonitor.multipleTargets.sharedAuthModule.name }}
{{- else }}
auth_module:
- client.{{ .name }}
{{- end }}
{{- end }}
{{- end }}
{{- if not .Values.serviceMonitor.multipleTargets.enabled -}}
endpoints:
- port: {{ .Values.service.name }}
{{- if .Values.serviceMonitor.interval }}
Expand All @@ -37,6 +83,7 @@ spec:
{{- with .Values.serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
jobLabel: {{ template "prometheus-postgres-exporter.fullname" . }}
namespaceSelector:
Expand Down
16 changes: 16 additions & 0 deletions charts/prometheus-postgres-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ serviceMonitor:
# TLS configuration to use when scraping the metric endpoint by Prometheus.
# tlsConfig: {}

# Use multipleTarget mode
multipleTargets:
festeveira marked this conversation as resolved.
Show resolved Hide resolved
enabled: false
# Use the same auth module for every target
# The config file should have a section like [$name]
sharedAuthModule:
enabled: false
name: ""

# Define each target's endpoint and name
# When not using sharedAuthModule the config file should have one authModule for each target like [client.$name]
targets: []
# - endpoint:
# name:
# port: default 5432
festeveira marked this conversation as resolved.
Show resolved Hide resolved

prometheusRule:
enabled: false
additionalLabels: {}
Expand Down