From c9e613ae2ea600687af04604444c3ff36a6eab35 Mon Sep 17 00:00:00 2001 From: Christian Rohmann Date: Mon, 12 Aug 2024 10:43:41 +0200 Subject: [PATCH] Apply additional label to headless Service + ServiceMonitor to avoid duplicate scraping (#214) Add a common label `app.kubernetes.io/component` ([1]) with value `cluster-discovery` to the headless Service and the ServiceMonitor it's ensured metrics are only scraped once. Using the headless service also makes the most sense, as it has the sole purpose of discovering all Pods making up a qdrant cluster. With `publishNotReadyAddresses: true` metrics are also collected from non-ready pods, see [2]. This is helpful to also collect metrics from Pods that might never become ready to use them for e.g. alerting and problem analysis [1] https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/#labels [2] https://github.com/prometheus-operator/prometheus-operator/discussions/5693 Fixes: #207 --- charts/qdrant/templates/service-headless.yaml | 1 + charts/qdrant/templates/servicemonitor.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/charts/qdrant/templates/service-headless.yaml b/charts/qdrant/templates/service-headless.yaml index f39e08b..4b1234e 100644 --- a/charts/qdrant/templates/service-headless.yaml +++ b/charts/qdrant/templates/service-headless.yaml @@ -4,6 +4,7 @@ metadata: name: {{ include "qdrant.fullname" . }}-headless labels: {{- include "qdrant.labels" . | nindent 4 }} + app.kubernetes.io/component: cluster-discovery {{- with .Values.service.additionalLabels }} {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/qdrant/templates/servicemonitor.yaml b/charts/qdrant/templates/servicemonitor.yaml index b6b7386..d2c7ca8 100644 --- a/charts/qdrant/templates/servicemonitor.yaml +++ b/charts/qdrant/templates/servicemonitor.yaml @@ -40,4 +40,5 @@ spec: selector: matchLabels: {{- include "qdrant.labels" . | nindent 6 }} + app.kubernetes.io/component: cluster-discovery {{- end }}