apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ .Values.name }}-{{ .Release.Namespace }}
  namespace: {{ .Values.monitoring.namespace }}
  labels:
    app: {{ .Values.exporter.name }}
    namespace: {{ .Release.Namespace }}
    relatedNamespace: {{ .Release.Namespace }}
spec:
  endpoints:
    - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
      interval: 30s
      path: {{ .Values.monitoring.prometheusScrapePath }}
      scheme: http
      targetPort: {{ .Values.port }}
  jobLabel: {{ .Values.monitoring.jobLabel }}
  namespaceSelector:
    matchNames:
      - {{ .Release.Namespace }}
  selector:
    matchLabels:
      app: {{ .Values.exporter.name }}
