{{- if and .Values.exporter.enabled .Values.exporter.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ template "cassandra.fullname" . }}
  labels:
    app: {{ template "cassandra.name" . }}
    chart: {{ template "cassandra.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    {{- if .Values.exporter.serviceMonitor.additionalLabels }}
{{ toYaml .Values.exporter.serviceMonitor.additionalLabels | indent 4 }}
    {{- end }}
spec:
  jobLabel: {{ template "cassandra.name" . }}
  endpoints:
  - port: metrics
    interval: 10s
  selector:
    matchLabels:
      app: {{ template "cassandra.name" . }}
  namespaceSelector:
    any: true
{{- end }}
