servicemonitor.yaml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {{- /*
  2. Copyright VMware, Inc.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. {{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
  6. apiVersion: monitoring.coreos.com/v1
  7. kind: ServiceMonitor
  8. metadata:
  9. name: {{ include "postgresql.v1.primary.fullname" . }}
  10. namespace: {{ default .Release.Namespace .Values.metrics.serviceMonitor.namespace | quote }}
  11. {{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics.serviceMonitor.labels .Values.commonLabels ) "context" . ) }}
  12. labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
  13. app.kubernetes.io/component: metrics
  14. {{- if .Values.commonAnnotations }}
  15. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. {{- if .Values.metrics.serviceMonitor.jobLabel }}
  19. jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel }}
  20. {{- end }}
  21. selector:
  22. {{- $svcLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics.serviceMonitor.selector .Values.commonLabels ) "context" . ) }}
  23. matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $svcLabels "context" $ ) | nindent 6 }}
  24. app.kubernetes.io/component: metrics
  25. endpoints:
  26. - port: http-metrics
  27. {{- if .Values.metrics.serviceMonitor.interval }}
  28. interval: {{ .Values.metrics.serviceMonitor.interval }}
  29. {{- end }}
  30. {{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
  31. scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
  32. {{- end }}
  33. {{- if .Values.metrics.serviceMonitor.relabelings }}
  34. relabelings: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.relabelings "context" $) | nindent 6 }}
  35. {{- end }}
  36. {{- if .Values.metrics.serviceMonitor.metricRelabelings }}
  37. metricRelabelings: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.metricRelabelings "context" $) | nindent 6 }}
  38. {{- end }}
  39. {{- if .Values.metrics.serviceMonitor.honorLabels }}
  40. honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }}
  41. {{- end }}
  42. namespaceSelector:
  43. matchNames:
  44. - {{ .Release.Namespace | quote }}
  45. {{- end }}