{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ template "memcached.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "memcached.labels" . | indent 4 }}
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "memcached.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  endpoints:
  - port: metrics
    interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- end }}
