From 00767365e012aa49fe3bb50776379edc2bb0f92c Mon Sep 17 00:00:00 2001 From: Valentin Zayash Date: Thu, 2 Apr 2020 19:44:24 +0300 Subject: [PATCH] Conditional cadvisor metrics for kubelet serviceMonitor (#21653) Signed-off-by: Valentin Zayash --- stable/prometheus-operator/Chart.yaml | 2 +- stable/prometheus-operator/README.md | 1 + .../templates/exporters/kubelet/servicemonitor.yaml | 4 ++++ stable/prometheus-operator/values.yaml | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/stable/prometheus-operator/Chart.yaml b/stable/prometheus-operator/Chart.yaml index d68fdeff85..4cef0318b5 100644 --- a/stable/prometheus-operator/Chart.yaml +++ b/stable/prometheus-operator/Chart.yaml @@ -12,7 +12,7 @@ sources: - https://github.com/coreos/kube-prometheus - https://github.com/coreos/prometheus-operator - https://coreos.com/operators/prometheus -version: 8.12.6 +version: 8.12.7 appVersion: 0.37.0 tillerVersion: ">=2.12.0" home: https://github.com/coreos/prometheus-operator diff --git a/stable/prometheus-operator/README.md b/stable/prometheus-operator/README.md index ff0f263bc9..de8cbf6b0f 100644 --- a/stable/prometheus-operator/README.md +++ b/stable/prometheus-operator/README.md @@ -524,6 +524,7 @@ For a full list of configurable values please refer to the [Grafana chart](https | `kubeStateMetrics.serviceMonitor.relabelings` | The `relabel_configs` for scraping `kube-state-metrics`. | `` | | `kubelet.enabled` | Deploy servicemonitor to scrape the kubelet service. See also `prometheusOperator.kubeletService` | `true` | | `kubelet.namespace` | Namespace where the kubelet is deployed. See also `prometheusOperator.kubeletService.namespace` | `kube-system` | +| `kubelet.serviceMonitor.cAdvisor` | Enable scraping `/metrics/cadvisor` from kubelet's service | `true` | | `kubelet.serviceMonitor.cAdvisorMetricRelabelings` | The `metric_relabel_configs` for scraping cAdvisor. | `` | | `kubelet.serviceMonitor.cAdvisorRelabelings` | The `relabel_configs` for scraping cAdvisor. | `[{"sourceLabels":["__metrics_path__"], "targetLabel":"metrics_path"}]` | | `kubelet.serviceMonitor.https` | Enable scraping of the kubelet over HTTPS. For more information, see https://github.com/coreos/prometheus-operator/issues/926 | `true` | diff --git a/stable/prometheus-operator/templates/exporters/kubelet/servicemonitor.yaml b/stable/prometheus-operator/templates/exporters/kubelet/servicemonitor.yaml index b907615ff1..fe78e73d41 100644 --- a/stable/prometheus-operator/templates/exporters/kubelet/servicemonitor.yaml +++ b/stable/prometheus-operator/templates/exporters/kubelet/servicemonitor.yaml @@ -28,6 +28,7 @@ spec: relabelings: {{ toYaml .Values.kubelet.serviceMonitor.relabelings | indent 4 }} {{- end }} +{{- if .Values.kubelet.serviceMonitor.cAdvisor }} - port: https-metrics scheme: https path: /metrics/cadvisor @@ -46,6 +47,7 @@ spec: {{- if .Values.kubelet.serviceMonitor.cAdvisorRelabelings }} relabelings: {{ toYaml .Values.kubelet.serviceMonitor.cAdvisorRelabelings | indent 4 }} +{{- end }} {{- end }} {{- else }} - port: http-metrics @@ -61,6 +63,7 @@ spec: relabelings: {{ toYaml .Values.kubelet.serviceMonitor.relabelings | indent 4 }} {{- end }} +{{- if .Values.kubelet.serviceMonitor.cAdvisor }} - port: http-metrics path: /metrics/cadvisor {{- if .Values.kubelet.serviceMonitor.interval }} @@ -74,6 +77,7 @@ spec: {{- if .Values.kubelet.serviceMonitor.cAdvisorRelabelings }} relabelings: {{ toYaml .Values.kubelet.serviceMonitor.cAdvisorRelabelings | indent 4 }} +{{- end }} {{- end }} {{- end }} jobLabel: k8s-app diff --git a/stable/prometheus-operator/values.yaml b/stable/prometheus-operator/values.yaml index cca45b78f9..8641e3cfc1 100644 --- a/stable/prometheus-operator/values.yaml +++ b/stable/prometheus-operator/values.yaml @@ -566,6 +566,10 @@ kubelet: ## https: true + ## Enable scraping /metrics/cadvisor from kubelet's service + ## + cAdvisor: true + ## Metric relabellings to apply to samples before ingestion ## cAdvisorMetricRelabelings: []