servicemonitor.yaml 2.0 KB

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