servicemonitor.yaml 2.4 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 | quote }}
  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. selector:
  24. matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
  25. {{- if .Values.metrics.serviceMonitor.selector }}
  26. {{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.selector "context" $) | nindent 6 }}
  27. {{- end }}
  28. endpoints:
  29. - port: http-metrics
  30. path: "/metrics"
  31. {{- if .Values.metrics.serviceMonitor.interval }}
  32. interval: {{ .Values.metrics.serviceMonitor.interval }}
  33. {{- end }}
  34. {{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
  35. scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
  36. {{- end }}
  37. {{- if .Values.metrics.serviceMonitor.honorLabels }}
  38. honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }}
  39. {{- end }}
  40. {{- if .Values.metrics.serviceMonitor.metricRelabelings }}
  41. metricRelabelings: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.metricRelabelings "context" $) | nindent 8 }}
  42. {{- end }}
  43. {{- if .Values.metrics.serviceMonitor.relabelings }}
  44. relabelings: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.relabelings "context" $) | nindent 8 }}
  45. {{- end }}
  46. namespaceSelector:
  47. matchNames:
  48. - {{ include "common.names.namespace" . | quote }}
  49. {{- end }}