servicemonitor.yaml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. {{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
  2. apiVersion: monitoring.coreos.com/v1
  3. kind: ServiceMonitor
  4. metadata:
  5. name: {{ include "common.names.fullname" . }}
  6. namespace: {{ default (include "common.names.namespace" .) .Values.metrics.serviceMonitor.namespace }}
  7. labels: {{- include "common.labels.standard" . | nindent 4 }}
  8. {{- if .Values.metrics.serviceMonitor.labels }}
  9. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.labels "context" $ ) | nindent 4 }}
  10. {{- end }}
  11. {{- if .Values.commonLabels }}
  12. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  13. {{- end }}
  14. annotations:
  15. {{- if .Values.commonAnnotations }}
  16. {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  17. {{- end }}
  18. {{- if .Values.metrics.serviceMonitor.annotations }}
  19. {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.annotations "context" $ ) | nindent 4 }}
  20. {{- end }}
  21. spec:
  22. jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel | quote }}
  23. endpoints:
  24. - port: metrics
  25. {{- if .Values.metrics.serviceMonitor.interval }}
  26. interval: {{ .Values.metrics.serviceMonitor.interval }}
  27. {{- end }}
  28. {{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
  29. scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
  30. {{- end }}
  31. {{- if .Values.metrics.serviceMonitor.honorLabels }}
  32. honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }}
  33. {{- end }}
  34. {{- if .Values.metrics.serviceMonitor.metricRelabelings }}
  35. metricRelabelings: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.metricRelabelings "context" $) | nindent 8 }}
  36. {{- end }}
  37. {{- if .Values.metrics.serviceMonitor.relabelings }}
  38. relabelings: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.relabelings "context" $) | nindent 8 }}
  39. {{- end }}
  40. namespaceSelector:
  41. matchNames:
  42. - {{ include "common.names.namespace" . | quote }}
  43. selector:
  44. matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
  45. app.kubernetes.io/component: metrics
  46. {{- if .Values.metrics.serviceMonitor.selector }}
  47. {{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.selector "context" $) | nindent 6 }}
  48. {{- end }}
  49. {{- end }}