{{- if and ((.Values.metaMonitoring).grafanaAgent).enabled .Values.metaMonitoring.grafanaAgent.metrics.scrapeK8s.enabled }} {{- with .Values.metaMonitoring.serviceMonitor }} {{- if .enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ include "tempo.resourceName" (dict "ctx" $ "component" "k8s-ksm") }} namespace: {{ .namespace | default $.Release.Namespace | quote }} labels: {{- include "tempo.labels" (dict "ctx" $ "component" "meta-monitoring") | nindent 4 }} {{- with .labels }} {{- toYaml . | nindent 4 }} {{- end }} {{- with .annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: endpoints: - port: http-metrics metricRelabelings: - action: keep regex: {{ include "tempo.resourceName" (dict "ctx" $) }}.* sourceLabels: - deployment - statefulset - pod separator: '' path: /metrics honorLabels: true # retain namespace label from kube-state-metrics {{- with .scrapeTimeout }} scrapeTimeout: {{ . }} {{- end }} {{- with ((((($.Values).metaMonitoring).grafanaAgent).metrics).scrapeK8s).kubeStateMetrics }} namespaceSelector: matchNames: - {{ .namespace }} selector: matchLabels: {{- toYaml .labelSelectors | nindent 6 }} {{- end -}} {{- end -}} {{- end -}} {{- end -}}