blob: 8ab16f0b250112764e4e775bc60b9af1af61c724 [file] [log] [blame]
Giorgi Lekveishvilicccf72f2023-05-19 16:13:22 +04001{{- if and .Values.controller.metrics.enabled .Values.controller.metrics.serviceMonitor.enabled -}}
Giorgi Lekveishvili725bb392023-05-05 18:24:27 +04002apiVersion: monitoring.coreos.com/v1
3kind: ServiceMonitor
4metadata:
5 name: {{ include "ingress-nginx.controller.fullname" . }}
6{{- if .Values.controller.metrics.serviceMonitor.namespace }}
7 namespace: {{ .Values.controller.metrics.serviceMonitor.namespace | quote }}
8{{- end }}
9 labels:
10 {{- include "ingress-nginx.labels" . | nindent 4 }}
11 app.kubernetes.io/component: controller
12 {{- if .Values.controller.metrics.serviceMonitor.additionalLabels }}
13 {{- toYaml .Values.controller.metrics.serviceMonitor.additionalLabels | nindent 4 }}
14 {{- end }}
15spec:
16 endpoints:
Giorgi Lekveishvilicccf72f2023-05-19 16:13:22 +040017 - port: {{ .Values.controller.metrics.portName }}
Giorgi Lekveishvili725bb392023-05-05 18:24:27 +040018 interval: {{ .Values.controller.metrics.serviceMonitor.scrapeInterval }}
19 {{- if .Values.controller.metrics.serviceMonitor.honorLabels }}
20 honorLabels: true
21 {{- end }}
Giorgi Lekveishvilicccf72f2023-05-19 16:13:22 +040022 {{- if .Values.controller.metrics.serviceMonitor.relabelings }}
23 relabelings: {{ toYaml .Values.controller.metrics.serviceMonitor.relabelings | nindent 8 }}
24 {{- end }}
Giorgi Lekveishvili725bb392023-05-05 18:24:27 +040025 {{- if .Values.controller.metrics.serviceMonitor.metricRelabelings }}
26 metricRelabelings: {{ toYaml .Values.controller.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
27 {{- end }}
28{{- if .Values.controller.metrics.serviceMonitor.jobLabel }}
29 jobLabel: {{ .Values.controller.metrics.serviceMonitor.jobLabel | quote }}
30{{- end }}
31{{- if .Values.controller.metrics.serviceMonitor.namespaceSelector }}
32 namespaceSelector: {{ toYaml .Values.controller.metrics.serviceMonitor.namespaceSelector | nindent 4 }}
Giorgi Lekveishvilicccf72f2023-05-19 16:13:22 +040033{{- else }}
Giorgi Lekveishvili725bb392023-05-05 18:24:27 +040034 namespaceSelector:
35 matchNames:
36 - {{ .Release.Namespace }}
37{{- end }}
38{{- if .Values.controller.metrics.serviceMonitor.targetLabels }}
39 targetLabels:
40 {{- range .Values.controller.metrics.serviceMonitor.targetLabels }}
41 - {{ . }}
42 {{- end }}
43{{- end }}
44 selector:
45 matchLabels:
46 {{- include "ingress-nginx.selectorLabels" . | nindent 6 }}
47 app.kubernetes.io/component: controller
48{{- end }}