Skip to content

Commit 2bc83a2

Browse files
Merge pull request #383 from jkroepke/service-monitor
[helm] Add support for relabelings and metricRelabelings for serviceMonitor/podMonitor
2 parents 9463cd5 + 09babe4 commit 2bc83a2

File tree

3 files changed

+157
-25
lines changed

3 files changed

+157
-25
lines changed

deployments/kubernetes/chart/reloader/templates/podmonitor.yaml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
apiVersion: monitoring.coreos.com/v1
33
kind: PodMonitor
44
metadata:
5+
{{- if .Values.reloader.podMonitor.annotations }}
6+
annotations:
7+
{{ tpl (toYaml .Values.reloader.podMonitor.annotations) . | indent 4 }}
8+
{{- end }}
59
labels:
610
{{ include "reloader-labels.chart" . | indent 4 }}
711
{{- if .Values.reloader.podMonitor.labels }}
@@ -15,12 +19,35 @@ spec:
1519
podMetricsEndpoints:
1620
- port: http
1721
path: "/metrics"
18-
{{- if .Values.reloader.podMonitor.interval }}
19-
interval: {{ .Values.reloader.podMonitor.interval }}
20-
{{- end }}
21-
{{- if .Values.reloader.podMonitor.timeout }}
22-
scrapeTimeout: {{ .Values.reloader.podMonitor.timeout }}
23-
{{- end }}
22+
{{- with .Values.reloader.podMonitor.interval }}
23+
interval: {{ . }}
24+
{{- end }}
25+
{{- with .Values.reloader.podMonitor.scheme }}
26+
scheme: {{ . }}
27+
{{- end }}
28+
{{- with .Values.reloader.podMonitor.bearerTokenSecret }}
29+
bearerTokenSecret: {{ . }}
30+
{{- end }}
31+
{{- with .Values.reloader.podMonitor.tlsConfig }}
32+
tlsConfig:
33+
{{- toYaml .| nindent 6 }}
34+
{{- end }}
35+
{{- with .Values.reloader.podMonitor.timeout }}
36+
scrapeTimeout: {{ . }}
37+
{{- end }}
38+
honorLabels: {{ .Values.reloader.podMonitor.honorLabels }}
39+
{{- with .Values.reloader.podMonitor.metricRelabelings }}
40+
metricRelabelings:
41+
{{- tpl (toYaml . | nindent 6) $ }}
42+
{{- end }}
43+
{{- with .Values.reloader.podMonitor.relabelings }}
44+
relabelings:
45+
{{- toYaml . | nindent 6 }}
46+
{{- end }}
47+
{{- with .Values.reloader.podMonitor.podTargetLabels }}
48+
podTargetLabels:
49+
{{- toYaml . | nindent 4 }}
50+
{{- end }}
2451
jobLabel: {{ template "reloader-fullname" . }}
2552
namespaceSelector:
2653
matchNames:

deployments/kubernetes/chart/reloader/templates/servicemonitor.yaml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:
5+
{{- if .Values.reloader.serviceMonitor.annotations }}
6+
annotations:
7+
{{ tpl (toYaml .Values.reloader.serviceMonitor.annotations) . | indent 4 }}
8+
{{- end }}
59
labels:
610
{{ include "reloader-labels.chart" . | indent 4 }}
711
{{- if .Values.reloader.serviceMonitor.labels }}
@@ -15,12 +19,35 @@ spec:
1519
endpoints:
1620
- targetPort: http
1721
path: "/metrics"
18-
{{- if .Values.reloader.serviceMonitor.interval }}
19-
interval: {{ .Values.reloader.serviceMonitor.interval }}
20-
{{- end }}
21-
{{- if .Values.reloader.serviceMonitor.timeout }}
22-
scrapeTimeout: {{ .Values.reloader.serviceMonitor.timeout }}
23-
{{- end }}
22+
{{- with .Values.reloader.serviceMonitor.interval }}
23+
interval: {{ . }}
24+
{{- end }}
25+
{{- with .Values.reloader.serviceMonitor.scheme }}
26+
scheme: {{ . }}
27+
{{- end }}
28+
{{- with .Values.reloader.serviceMonitor.bearerTokenFile }}
29+
bearerTokenFile: {{ . }}
30+
{{- end }}
31+
{{- with .Values.reloader.serviceMonitor.tlsConfig }}
32+
tlsConfig:
33+
{{- toYaml .| nindent 6 }}
34+
{{- end }}
35+
{{- with .Values.reloader.serviceMonitor.timeout }}
36+
scrapeTimeout: {{ . }}
37+
{{- end }}
38+
honorLabels: {{ .Values.reloader.serviceMonitor.honorLabels }}
39+
{{- with .Values.reloader.serviceMonitor.metricRelabelings }}
40+
metricRelabelings:
41+
{{- tpl (toYaml . | nindent 6) $ }}
42+
{{- end }}
43+
{{- with .Values.reloader.serviceMonitor.relabelings }}
44+
relabelings:
45+
{{- toYaml . | nindent 6 }}
46+
{{- end }}
47+
{{- with .Values.reloader.serviceMonitor.targetLabels }}
48+
targetLabels:
49+
{{- toYaml . | nindent 4 }}
50+
{{- end }}
2451
jobLabel: {{ template "reloader-fullname" . }}
2552
namespaceSelector:
2653
matchNames:

deployments/kubernetes/chart/reloader/values.yaml

Lines changed: 91 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ reloader:
137137
annotations: {}
138138
# The name of the ServiceAccount to use.
139139
# If not set and create is true, a name is generated using the fullname template
140-
name:
140+
name:
141141
# Optional flags to pass to the Reloader entrypoint
142142
# Example:
143143
# custom_annotations:
@@ -151,23 +151,101 @@ reloader:
151151
enabled: false
152152
# Set the namespace the ServiceMonitor should be deployed
153153
# namespace: monitoring
154-
# Set how frequently Prometheus should scrape
155-
# interval: 30s
156-
# Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator
157-
# labels:
158-
# Set timeout for scrape
159-
# timeout: 10s
154+
155+
# Fallback to the prometheus default unless specified
156+
# interval: 10s
157+
158+
## scheme: HTTP scheme to use for scraping. Can be used with `tlsConfig` for example if using istio mTLS.
159+
# scheme: ""
160+
161+
## tlsConfig: TLS configuration to use when scraping the endpoint. For example if using istio mTLS.
162+
## Of type: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#tlsconfig
163+
# tlsConfig: {}
164+
165+
# bearerTokenFile:
166+
# Fallback to the prometheus default unless specified
167+
# timeout: 30s
168+
169+
## Used to pass Labels that are used by the Prometheus installed in your cluster to select Service Monitors to work with
170+
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
171+
labels: {}
172+
173+
## Used to pass annotations that are used by the Prometheus installed in your cluster to select Service Monitors to work with
174+
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
175+
annotations: {}
176+
177+
# Retain the job and instance labels of the metrics pushed to the Pushgateway
178+
# [Scraping Pushgateway](https://github.com/prometheus/pushgateway#configure-the-pushgateway-as-a-target-to-scrape)
179+
honorLabels: true
180+
181+
## Metric relabel configs to apply to samples before ingestion.
182+
## [Metric Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs)
183+
metricRelabelings: []
184+
# - action: keep
185+
# regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+'
186+
# sourceLabels: [__name__]
187+
188+
## Relabel configs to apply to samples before ingestion.
189+
## [Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config)
190+
relabelings: []
191+
# - sourceLabels: [__meta_kubernetes_pod_node_name]
192+
# separator: ;
193+
# regex: ^(.*)$
194+
# targetLabel: nodename
195+
# replacement: $1
196+
# action: replace
197+
198+
targetLabels: []
160199

161200
podMonitor:
162201
enabled: false
163202
# Set the namespace the podMonitor should be deployed
164203
# namespace: monitoring
165-
# Set how frequently Prometheus should scrape
166-
# interval: 30s
167-
# Set labels for the podMonitor, use this to define your scrape label for Prometheus Operator
168-
# labels:
169-
# Set timeout for scrape
170-
# timeout: 10s
204+
205+
# Fallback to the prometheus default unless specified
206+
# interval: 10s
207+
208+
## scheme: HTTP scheme to use for scraping. Can be used with `tlsConfig` for example if using istio mTLS.
209+
# scheme: ""
210+
211+
## tlsConfig: TLS configuration to use when scraping the endpoint. For example if using istio mTLS.
212+
## Of type: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#tlsconfig
213+
# tlsConfig: {}
214+
215+
# bearerTokenSecret:
216+
# Fallback to the prometheus default unless specified
217+
# timeout: 30s
218+
219+
## Used to pass Labels that are used by the Prometheus installed in your cluster to select Service Monitors to work with
220+
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
221+
labels: {}
222+
223+
## Used to pass annotations that are used by the Prometheus installed in your cluster to select Service Monitors to work with
224+
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
225+
annotations: {}
226+
227+
# Retain the job and instance labels of the metrics pushed to the Pushgateway
228+
# [Scraping Pushgateway](https://github.com/prometheus/pushgateway#configure-the-pushgateway-as-a-target-to-scrape)
229+
honorLabels: true
230+
231+
## Metric relabel configs to apply to samples before ingestion.
232+
## [Metric Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs)
233+
metricRelabelings: []
234+
# - action: keep
235+
# regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+'
236+
# sourceLabels: [__name__]
237+
238+
## Relabel configs to apply to samples before ingestion.
239+
## [Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config)
240+
relabelings: []
241+
# - sourceLabels: [__meta_kubernetes_pod_node_name]
242+
# separator: ;
243+
# regex: ^(.*)$
244+
# targetLabel: nodename
245+
# replacement: $1
246+
# action: replace
247+
248+
podTargetLabels: []
171249

172250
podDisruptionBudget:
173251
enabled: false

0 commit comments

Comments
 (0)