Skip to content

Commit b7a935f

Browse files
committed
ziti-controller: Add prometheus serviceMonitor
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
1 parent 06ce2d5 commit b7a935f

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{{- with .Values.prometheus }}
2+
{{- if and .service.enabled .serviceMonitor.enabled }}
3+
apiVersion: monitoring.coreos.com/v1
4+
kind: ServiceMonitor
5+
metadata:
6+
name: {{ include "ziti-controller.fullname" $ }}
7+
{{- with .serviceMonitor.namespace }}
8+
namespace: {{ . }}
9+
{{- end }}
10+
{{- with .serviceMonitor.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
labels:
15+
{{- include "ziti-controller.labels" $ | nindent 4 }}
16+
{{- with .serviceMonitor.labels }}
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
spec:
20+
{{- with .serviceMonitor.namespaceSelector }}
21+
namespaceSelector:
22+
{{- toYaml . | nindent 4 }}
23+
{{- end }}
24+
selector:
25+
matchLabels:
26+
{{- include "ziti-controller.selectorLabels" $ | nindent 6 }}
27+
{{- with .service.labels }}
28+
{{- toYaml . | nindent 6 }}
29+
{{- end }}
30+
endpoints:
31+
- port: prometheus
32+
{{- with $.Values.httpPathPrefix }}
33+
path: {{ printf "%s/metrics" . }}
34+
{{- end }}
35+
{{- with .serviceMonitor.interval }}
36+
interval: {{ . }}
37+
{{- end }}
38+
{{- with .serviceMonitor.scrapeTimeout }}
39+
scrapeTimeout: {{ . }}
40+
{{- end }}
41+
{{- with .serviceMonitor.relabelings }}
42+
relabelings:
43+
{{- toYaml . | nindent 8 }}
44+
{{- end }}
45+
{{- with .serviceMonitor.metricRelabelings }}
46+
metricRelabelings:
47+
{{- toYaml . | nindent 8 }}
48+
{{- end }}
49+
{{- with .serviceMonitor.scheme }}
50+
scheme: {{ . }}
51+
{{- end }}
52+
{{- with .serviceMonitor.tlsConfig }}
53+
tlsConfig:
54+
{{- toYaml . | nindent 8 }}
55+
{{- end }}
56+
{{- with .serviceMonitor.targetLabels }}
57+
targetLabels:
58+
{{- toYaml . | nindent 4 }}
59+
{{- end }}
60+
{{- end }}
61+
{{- end }}

charts/ziti-controller/values.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,44 @@ prometheus:
8282
enabled: false
8383
# -- expose the service as a ClusterIP, NodePort, or LoadBalancer
8484
type: ClusterIP
85-
labels: {}
85+
# -- extra labels for matching only this service, ie. serviceMonitor
86+
labels:
87+
app: "prometheus"
8688
annotations: {}
8789

90+
# ServiceMonitor configuration
91+
serviceMonitor:
92+
# -- If enabled, and prometheus service is enabled, ServiceMonitor resources for Prometheus Operator are created
93+
enabled: true
94+
# -- Alternative namespace for ServiceMonitor resources
95+
namespace: null
96+
# -- Namespace selector for ServiceMonitor resources
97+
namespaceSelector: {}
98+
# -- ServiceMonitor annotations
99+
annotations: {}
100+
# -- Additional ServiceMonitor labels
101+
labels: {}
102+
# -- ServiceMonitor scrape interval
103+
interval: null
104+
# -- ServiceMonitor scrape timeout in Go duration format (e.g. 15s)
105+
scrapeTimeout: null
106+
# -- ServiceMonitor relabel configs to apply to samples before scraping
107+
# https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig
108+
# (defines `relabel_configs`)
109+
relabelings: []
110+
# -- ServiceMonitor relabel configs to apply to samples as the last
111+
# step before ingestion
112+
# https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig
113+
# (defines `metric_relabel_configs`)
114+
metricRelabelings: []
115+
# -- ServiceMonitor will add labels from the service to the Prometheus metric
116+
# https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitorspec
117+
targetLabels: []
118+
# -- ServiceMonitor will use http by default, but you can pick https as well
119+
scheme: https
120+
# -- ServiceMonitor will use these tlsConfig settings to make the health check requests
121+
tlsConfig: null
122+
88123
ca:
89124
# Note: The renewBefore and duration fields must be specified using a Go
90125
# time.Duration string format, which does not allow the d (days) suffix.

0 commit comments

Comments
 (0)