{{- if and .Values.serviceMonitor.enabled .Values.serviceMonitor.metricsEndpoints (or (eq .Values.mode "deployment") (eq .Values.mode "statefulset")) }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ include "opentelemetry-collector.fullname" . }} namespace: {{ template "opentelemetry-collector.namespace" . }} labels: {{- include "opentelemetry-collector.labels" . | nindent 4 }} {{- range $key, $value := .Values.serviceMonitor.extraLabels }} {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} {{- end }} spec: selector: matchLabels: {{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }} {{- include "opentelemetry-collector.component" . | nindent 6 }} endpoints: {{- toYaml .Values.serviceMonitor.metricsEndpoints | nindent 2 }} {{- end }}