{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ include "vaultfire.fullname" . }}
  labels:
    {{- include "vaultfire.labels" . | nindent 4 }}
    {{- range $key, $value := .Values.metrics.serviceMonitor.additionalLabels }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
spec:
  selector:
    matchLabels:
      {{- include "vaultfire.selectorLabels" . | nindent 6 }}
  endpoints:
    - port: trust-sync
      interval: {{ .Values.metrics.serviceMonitor.interval }}
      path: {{ .Values.metrics.path }}
    - port: partner-sync
      interval: {{ .Values.metrics.serviceMonitor.interval }}
      path: {{ .Values.metrics.path }}
{{- end }}
