From 44e36980a1f0d48bd766e1b73093741e46827122 Mon Sep 17 00:00:00 2001 From: Arbin Date: Thu, 29 Jan 2026 01:21:15 +0800 Subject: [PATCH 1/2] fix(fluent-bit): support additionalLabels in ServiceMonitor Add support for serviceMonitor.additionalLabels to align with prometheusRule.additionalLabels pattern. This allows Prometheus Operator to discover the ServiceMonitor using label selectors. The existing selector field is maintained for backward compatibility, with additionalLabels taking precedence when both are defined. Fixes fluent#1234 Signed-off-by: Arbin --- charts/fluent-bit/templates/servicemonitor.yaml | 4 ++++ charts/fluent-bit/values.yaml | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/charts/fluent-bit/templates/servicemonitor.yaml b/charts/fluent-bit/templates/servicemonitor.yaml index 75ba026d..995049b4 100644 --- a/charts/fluent-bit/templates/servicemonitor.yaml +++ b/charts/fluent-bit/templates/servicemonitor.yaml @@ -6,9 +6,13 @@ metadata: namespace: {{ default .Release.Namespace .Values.serviceMonitor.namespace }} labels: {{- include "fluent-bit.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- else }} {{- with .Values.serviceMonitor.selector }} {{- toYaml . | nindent 4 }} {{- end }} + {{- end }} spec: jobLabel: app.kubernetes.io/instance endpoints: diff --git a/charts/fluent-bit/values.yaml b/charts/fluent-bit/values.yaml index 5de1d0a2..675f9dbf 100644 --- a/charts/fluent-bit/values.yaml +++ b/charts/fluent-bit/values.yaml @@ -121,8 +121,13 @@ serviceMonitor: # namespace: monitoring # interval: 10s # scrapeTimeout: 10s - # selector: - # prometheus: my-prometheus + # ## additionalLabels: Additional labels to add to the ServiceMonitor metadata + # ## This is the recommended way to add labels for Prometheus Operator selection + # additionalLabels: {} + # # prometheus: my-prometheus + # ## selector: (DEPRECATED) Use additionalLabels instead + # ## This field is maintained for backward compatibility but additionalLabels is preferred + # selector: {} # ## metric relabel configs to apply to samples before ingestion. # ## # metricRelabelings: From 05ee74b75d5962219b731cb0853b051172d95d3d Mon Sep 17 00:00:00 2001 From: Arbin Date: Thu, 29 Jan 2026 12:31:13 +0800 Subject: [PATCH 2/2] Breaking: Rename serviceMonitor.selector to additionalLabels - Renamed serviceMonitor.selector to serviceMonitor.additionalLabels for consistency with PrometheusRule - Updated CHANGELOG.md with breaking change entry (#691) - Updated values.yaml and templates/servicemonitor.yaml - Regenerated documentation with helm-docs - Fixed markdown formatting with rumdl - All tests verified: helm lint passes This is a breaking change acceptable for v0.x chart versions. Users need to rename 'selector' to 'additionalLabels' in their values.yaml. Signed-off-by: Arbin --- charts/fluent-bit/CHANGELOG.md | 4 ++++ charts/fluent-bit/templates/servicemonitor.yaml | 4 ---- charts/fluent-bit/values.yaml | 10 +++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/charts/fluent-bit/CHANGELOG.md b/charts/fluent-bit/CHANGELOG.md index f4729ca8..6b4bf81c 100644 --- a/charts/fluent-bit/CHANGELOG.md +++ b/charts/fluent-bit/CHANGELOG.md @@ -14,6 +14,10 @@ ## [UNRELEASED] +### Changed + +- **BREAKING**: Renamed `serviceMonitor.selector` to `serviceMonitor.additionalLabels` for consistency with PrometheusRule configuration. ([#691](https://github.com/fluent/helm-charts/pull/691)) _@kalavt_ + ## [v0.55.0] - 2026-01-22 ### Changed diff --git a/charts/fluent-bit/templates/servicemonitor.yaml b/charts/fluent-bit/templates/servicemonitor.yaml index 995049b4..8ab29486 100644 --- a/charts/fluent-bit/templates/servicemonitor.yaml +++ b/charts/fluent-bit/templates/servicemonitor.yaml @@ -8,10 +8,6 @@ metadata: {{- include "fluent-bit.labels" . | nindent 4 }} {{- with .Values.serviceMonitor.additionalLabels }} {{- toYaml . | nindent 4 }} - {{- else }} - {{- with .Values.serviceMonitor.selector }} - {{- toYaml . | nindent 4 }} - {{- end }} {{- end }} spec: jobLabel: app.kubernetes.io/instance diff --git a/charts/fluent-bit/values.yaml b/charts/fluent-bit/values.yaml index 675f9dbf..b2ee6dca 100644 --- a/charts/fluent-bit/values.yaml +++ b/charts/fluent-bit/values.yaml @@ -121,13 +121,9 @@ serviceMonitor: # namespace: monitoring # interval: 10s # scrapeTimeout: 10s - # ## additionalLabels: Additional labels to add to the ServiceMonitor metadata - # ## This is the recommended way to add labels for Prometheus Operator selection - # additionalLabels: {} - # # prometheus: my-prometheus - # ## selector: (DEPRECATED) Use additionalLabels instead - # ## This field is maintained for backward compatibility but additionalLabels is preferred - # selector: {} + # additionalLabels: + # prometheus: kube-prometheus + # release: prometheus # ## metric relabel configs to apply to samples before ingestion. # ## # metricRelabelings: