{{- if .Values.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: {{ template "prometheus-postgres-exporter.fullname" . }}
{{- with .Values.prometheusRule.namespace }}
  namespace: {{ . }}
{{- end }}
  labels:
    app: {{ template "prometheus-postgres-exporter.name" . }}
    chart: {{ template "prometheus-postgres-exporter.chart" . }}
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
{{- with .Values.prometheusRule.additionalLabels }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- with .Values.prometheusRule.rules }}
  groups:
    - name: {{ template "prometheus-postgres-exporter.name" $ }}
      rules: {{ tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- end }}
