Skip to content

Commit 9f6a62a

Browse files
authored
feat(helm): Add ServiceMonitor (#695)
# Description Adding support for `ServiceMonitor`. ## Checklist - [x] I have read the [contributing documentation](https://retina.sh/docs/contributing). - [x] I have tested the changes locally. - [x] I have followed the project's style guidelines. - [x] I have updated the documentation, if necessary. ## Screenshots (if applicable) or Testing Completed ![image (2)](https://github.com/user-attachments/assets/f377b3b0-c41f-48ce-8e1f-0eef562ecd73) ![image (1)](https://github.com/user-attachments/assets/c11a6aa0-e897-43a3-b29c-2c2625554fb0)
1 parent e35d692 commit 9f6a62a

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

deploy/legacy/manifests/controller/helm/retina/templates/podmonitor.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.metrics.podMonitor.enabled }}
1+
{{- if and (not .Values.metrics.serviceMonitor.enabled) .Values.metrics.podMonitor.enabled }}
22
apiVersion: monitoring.coreos.com/v1
33
kind: PodMonitor
44
metadata:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{{- if and (not .Values.metrics.podMonitor.enabled) .Values.metrics.serviceMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ include "retina.fullname" . }}
6+
namespace: {{ ternary .Values.metrics.serviceMonitor.namespace .Values.namespace (not (empty .Values.metrics.serviceMonitor.namespace)) }}
7+
labels:
8+
k8s-app: {{ include "retina.name" . }}
9+
{{- include "retina.labels" . | nindent 4 }}
10+
app.kubernetes.io/component: metrics
11+
{{- if .Values.metrics.serviceMonitor.additionalLabels }}
12+
{{- toYaml .Values.metrics.serviceMonitor.additionalLabels | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
endpoints:
16+
- targetPort: retina
17+
path: /metrics
18+
{{- if .Values.metrics.serviceMonitor.interval }}
19+
interval: {{ .Values.metrics.serviceMonitor.interval }}
20+
{{- end }}
21+
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
22+
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
23+
{{- end }}
24+
{{- if .Values.metrics.serviceMonitor.scheme }}
25+
scheme: {{ .Values.metrics.serviceMonitor.scheme }}
26+
{{- end }}
27+
{{- if .Values.metrics.serviceMonitor.tlsConfig }}
28+
tlsConfig: {{- .Values.metrics.serviceMonitor.tlsConfig | nindent 8 }}
29+
{{- end }}
30+
{{- if .Values.metrics.serviceMonitor.relabelings }}
31+
relabelings:
32+
{{- toYaml .Values.metrics.serviceMonitor.relabelings | nindent 8 }}
33+
{{- end }}
34+
{{- if .Values.metrics.serviceMonitor.metricRelabelings }}
35+
metricRelabelings:
36+
{{- toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
37+
{{- end }}
38+
namespaceSelector:
39+
matchNames:
40+
- {{ .Values.namespace }}
41+
selector:
42+
matchLabels:
43+
{{- include "retina.selectorLabels" . | nindent 6 }}
44+
app.kubernetes.io/component: networking
45+
{{- end }}

deploy/legacy/manifests/controller/helm/retina/values.yaml

+35-1
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,38 @@ metrics:
191191
## @param metrics.podMonitor.relabelings [array] Prometheus relabeling rules
192192
##
193193
relabelings: []
194-
194+
serviceMonitor:
195+
## @param metrics.serviceMonitor.enabled Create serviceMonitor Resource for scraping metrics using PrometheusOperator
196+
##
197+
enabled: false
198+
## @param metrics.serviceMonitor.namespace Namespace in which the serviceMonitor should be created
199+
##
200+
namespace: ~
201+
## @param metrics.serviceMonitor.interval Specify the interval at which metrics should be scraped
202+
##
203+
interval: 30s
204+
## @param metrics.serviceMonitor.scrapeTimeout Specify the timeout after which the scrape is ended
205+
##
206+
scrapeTimeout: 30s
207+
## @param metrics.serviceMonitor.additionalLabels [object] Additional labels that can be used so serviceMonitor will be discovered by Prometheus
208+
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
209+
##
210+
additionalLabels: {}
211+
## @param metrics.serviceMonitor.scheme Scheme to use for scraping
212+
##
213+
scheme: http
214+
## @param metrics.serviceMonitor.tlsConfig [object] TLS configuration used for scrape endpoints used by Prometheus
215+
## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#tlsconfig
216+
## e.g:
217+
## tlsConfig:
218+
## ca:
219+
## secret:
220+
## name: existingSecretName
221+
##
222+
tlsConfig: {}
223+
## @param metrics.serviceMonitor.relabelings [array] Prometheus relabeling rules to apply to samples before scraping
224+
##
225+
relabelings: []
226+
## @param metrics.serviceMonitor.metricRelabelings [array] Prometheus relabeling rules to apply to samples before ingestion
227+
##
228+
metricRelabelings: []

0 commit comments

Comments
 (0)