{{- if .Values.monitoring.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ include "switchboard.fullname" . }}
  labels:
    {{- include "switchboard.labels" . | nindent 4 }}
    {{- with .Values.monitoring.serviceMonitor.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
spec:
  selector:
    matchLabels:
      {{- include "switchboard.selectorLabels" . | nindent 6 }}
      app.kubernetes.io/component: backend
  endpoints:
    - port: http
      path: {{ .Values.monitoring.serviceMonitor.path | default "/metrics" }}
      interval: {{ .Values.monitoring.serviceMonitor.interval | default "30s" }}
{{- end }}
