servicemonitor.yaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {{- /*
  2. Copyright VMware, Inc.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. {{- if .Values.metrics.serviceMonitor.enabled }}
  6. {{- $releaseNamespace := default (include "common.names.namespace" .) .Values.metrics.serviceMonitor.namespace }}
  7. apiVersion: {{ default "monitoring.coreos.com/v1" .Values.metrics.serviceMonitor.apiVersion }}
  8. kind: ServiceMonitor
  9. metadata:
  10. name: {{ include "common.names.fullname" . }}
  11. namespace: {{ $releaseNamespace | quote }}
  12. {{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics.serviceMonitor.labels .Values.commonLabels ) "context" . ) }}
  13. labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
  14. {{- if .Values.commonAnnotations }}
  15. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. endpoints:
  19. {{- /* Backward Compatibility for .Values.metrics.serviceMonitor.path */}}
  20. {{- $paths := list }}
  21. {{- if (.Values.metrics.serviceMonitor.paths | empty | not) }}
  22. {{- $paths = .Values.metrics.serviceMonitor.paths }}
  23. {{- end }}
  24. {{- if (.Values.metrics.serviceMonitor.path | empty | not) }}
  25. {{- $paths = prepend $paths .Values.metrics.serviceMonitor.path }}
  26. {{- end }}
  27. {{- range $idx, $path := ($paths | uniq) }}
  28. {{- with $ }}
  29. - port: minio-api
  30. path: {{ $path }}
  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: {{- toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
  42. {{- end }}
  43. {{- if .Values.metrics.serviceMonitor.relabelings }}
  44. relabelings: {{- toYaml .Values.metrics.serviceMonitor.relabelings | nindent 8 }}
  45. {{- end }}
  46. {{- if .Values.tls.enabled }}
  47. scheme: https
  48. {{- end }}
  49. {{- if .Values.metrics.serviceMonitor.tlsConfig }}
  50. tlsConfig: {{- toYaml .Values.metrics.serviceMonitor.tlsConfig | nindent 8 }}
  51. {{- end }}
  52. {{- end }}
  53. {{- end }}
  54. {{- if .Values.metrics.serviceMonitor.jobLabel }}
  55. jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel }}
  56. {{- end }}
  57. namespaceSelector:
  58. matchNames:
  59. - {{ include "common.names.namespace" . | quote }}
  60. selector:
  61. matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
  62. {{- if .Values.metrics.serviceMonitor.selector }}
  63. {{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.selector "context" $) | nindent 6 }}
  64. {{- end }}
  65. {{- end }}