{{- if .Values.hamiServiceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ include "hami-webui.fullname" . }}-hami-svc-monitor
  namespace: {{ include "hami-webui.namespace" . }}
  labels:
    {{- include "hami-webui.labels" . | nindent 4 }}
    app.kubernetes.io/component: "hami-webui"
    {{- if .Values.hamiServiceMonitor.additionalLabels }}
    {{- toYaml .Values.hamiServiceMonitor.additionalLabels | nindent 4 }}
    {{- end }}
spec:
  selector:
    matchLabels:
      app.kubernetes.io/component: hami-device-plugin
  namespaceSelector:
    matchNames:
      - "{{ .Values.hamiServiceMonitor.svcNamespace }}"
  endpoints:
  - path: /metrics
    port: monitorport
    interval: "{{ .Values.hamiServiceMonitor.interval }}"
    honorLabels: {{ .Values.hamiServiceMonitor.honorLabels }}
    relabelings:
      {{ toYaml .Values.hamiServiceMonitor.relabelings | nindent 6 }}
{{- end -}}