[stable/prometheus-postgres-exporter]: add the ability to create a ServiceMonitor (#14918)

* Add the ability to create a ServiceMonitor

Signed-off-by: Dimitrios Karagiannis <dhkarag@gmail.com>

This is intended for users of the prometheus-operator helm chart.

* Update README with serviceMonitor values

Signed-off-by: Dimitrios Karagiannis <dhkarag@gmail.com>

* Remove missed comment

Signed-off-by: Dimitrios Karagiannis <dhkarag@gmail.com>

* Update chart version

Signed-off-by: Dimitrios Karagiannis <dhkarag@gmail.com>
This commit is contained in:
Dimitrios Karagiannis
2019-08-13 00:17:41 -07:00
committed by Kubernetes Prow Robot
parent 387bb25492
commit 970315e41e
4 changed files with 54 additions and 1 deletions
@@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "0.5.1"
description: A Helm chart for prometheus postgres-exporter
name: prometheus-postgres-exporter
version: 0.7.1
version: 0.7.2
home: https://github.com/wrouesnel/postgres_exporter
sources:
- https://github.com/wrouesnel/postgres_exporter
@@ -47,6 +47,12 @@ The following table lists the configurable parameters of the postgres Exporter c
| `service.targetPort` | The target port of the container | `9187` |
| `service.name` | Name of the service port | `http` |
| `service.labels` | Labels to add to the service | `{}` |
| `servicemonitor.enabled` | Use servicemonitor from prometheus operator | `false` |
| `servicemonitor.namespace` | Namespace thes Servicemonitor is installed in | |
| `servicemonitor.interval` | How frequently Prometheus should scrape | |
| `servicemonitor.telemetryPath` | path to cloudwatch-exporter telemtery-path | |
| `servicemonitor.labels` | labels for the ServiceMonitor passed to Prometheus Operator | `{}` |
| `servicemonitor.timeout` | Timeout after which the scrape is ended | |
| `resources` | | `{}` |
| `config.datasource` | Postgresql datasource configuration | see [values.yaml](values.yaml) |
| `config.queries` | SQL queries that the exporter will run | [postgres exporter defaults](https://github.com/wrouesnel/postgres_exporter/blob/master/queries.yaml) |
@@ -0,0 +1,33 @@
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
{{- if .Values.serviceMonitor.labels }}
labels:
{{ toYaml .Values.serviceMonitor.labels | indent 4}}
{{- end }}
name: {{ template "prometheus-postgres-exporter.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
endpoints:
- targetPort: {{ .Values.service.name }}
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.telemetryPath }}
path: {{ .Values.serviceMonitor.telemetryPath }}
{{- end }}
{{- if .Values.serviceMonitor.timeout }}
scrapeTimeout: {{ .Values.serviceMonitor.timeout }}
{{- end }}
jobLabel: {{ template "prometheus-postgres-exporter.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "prometheus-postgres-exporter.name" . }}
release: {{ .Release.Name }}
{{- end }}
@@ -17,6 +17,20 @@ service:
labels: {}
annotations: {}
serviceMonitor:
# When set true then use a ServiceMonitor to configure scraping
enabled: false
# Set the namespace the ServiceMonitor should be deployed
# namespace: monitoring
# Set how frequently Prometheus should scrape
# interval: 30s
# Set path to cloudwatch-exporter telemtery-path
# telemetryPath: /metrics
# Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator
# labels:
# Set timeout for scrape
# timeout: 10s
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little