| Giorgi Lekveishvili | cccf72f | 2023-05-19 16:13:22 +0400 | [diff] [blame^] | 1 | {{- if and .Values.controller.metrics.enabled .Values.controller.metrics.serviceMonitor.enabled -}} |
| Giorgi Lekveishvili | 725bb39 | 2023-05-05 18:24:27 +0400 | [diff] [blame] | 2 | apiVersion: monitoring.coreos.com/v1 |
| 3 | kind: ServiceMonitor |
| 4 | metadata: |
| 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 }} |
| 15 | spec: |
| 16 | endpoints: |
| Giorgi Lekveishvili | cccf72f | 2023-05-19 16:13:22 +0400 | [diff] [blame^] | 17 | - port: {{ .Values.controller.metrics.portName }} |
| Giorgi Lekveishvili | 725bb39 | 2023-05-05 18:24:27 +0400 | [diff] [blame] | 18 | interval: {{ .Values.controller.metrics.serviceMonitor.scrapeInterval }} |
| 19 | {{- if .Values.controller.metrics.serviceMonitor.honorLabels }} |
| 20 | honorLabels: true |
| 21 | {{- end }} |
| Giorgi Lekveishvili | cccf72f | 2023-05-19 16:13:22 +0400 | [diff] [blame^] | 22 | {{- if .Values.controller.metrics.serviceMonitor.relabelings }} |
| 23 | relabelings: {{ toYaml .Values.controller.metrics.serviceMonitor.relabelings | nindent 8 }} |
| 24 | {{- end }} |
| Giorgi Lekveishvili | 725bb39 | 2023-05-05 18:24:27 +0400 | [diff] [blame] | 25 | {{- 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 Lekveishvili | cccf72f | 2023-05-19 16:13:22 +0400 | [diff] [blame^] | 33 | {{- else }} |
| Giorgi Lekveishvili | 725bb39 | 2023-05-05 18:24:27 +0400 | [diff] [blame] | 34 | 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 }} |