From 48e640d86af91373f79f701fb6b1f351e8563e2e Mon Sep 17 00:00:00 2001 From: Erhhung Yuan Date: Fri, 9 May 2025 15:20:11 -0700 Subject: [PATCH 1/3] feat(fluent-operator): Add support for FB ServiceMonitor selector labels (#605) --- .../templates/fluentbit-servicemonitor.yaml | 13 +++++--- charts/fluent-operator/values.yaml | 31 ++++++++++++++++--- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml b/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml index e0b4ee39..935b025b 100644 --- a/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml +++ b/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml @@ -5,19 +5,24 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: fluent-bit + namespace: {{ template "fluent-operator.namespace" . }} labels: app.kubernetes.io/name: fluent-bit - namespace: {{ template "fluent-operator.namespace" . }} + {{- with .Values.fluentbit.serviceMonitor.selector }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: endpoints: - port: metrics - path: {{ .Values.fluentbit.serviceMonitor.path }} - interval: {{ .Values.fluentbit.serviceMonitor.interval }} + path: {{ .Values.fluentbit.serviceMonitor.path }} {{- if .Values.fluentbit.serviceMonitor.secure }} scheme: https + {{- if .Values.fluentbit.serviceMonitor.tlsConfig }} tlsConfig: {{- toYaml .Values.fluentbit.serviceMonitor.tlsConfig }} {{- end }} + {{- end }} + interval: {{ .Values.fluentbit.serviceMonitor.interval }} scrapeTimeout: {{ .Values.fluentbit.serviceMonitor.scrapeTimeout }} {{- with .Values.fluentbit.serviceMonitor.relabelings }} relabelings: @@ -35,7 +40,7 @@ spec: {{- end }} namespaceSelector: matchNames: - - {{ template "fluent-operator.namespace" . }} + - {{ template "fluent-operator.namespace" . }} {{- end }} {{- end }} {{- end }} diff --git a/charts/fluent-operator/values.yaml b/charts/fluent-operator/values.yaml index 093a7860..d9167ca6 100644 --- a/charts/fluent-operator/values.yaml +++ b/charts/fluent-operator/values.yaml @@ -77,15 +77,36 @@ fluentbit: # Installs a sub chart carrying the CRDs for the fluent-bit controller. The sub chart is enabled by default. crdsEnable: true enable: true + serviceMonitor: enable: false - interval: 30s + ## ServiceMonitor selector labels + # selector: + # release: prometheus-stack + ## additional service selector labels + # labels: {} path: /api/v2/metrics/prometheus - scrapeTimeout: 10s + ## applies "scheme: https" and tlsConfig if true secure: false - tlsConfig: {} - relabelings: [] - metricRelabelings: [] + # tlsConfig: {} + interval: 30s + scrapeTimeout: 10s + ## relabel configs to apply to samples after ingestion + # relabelings: + # - sourceLabels: [__meta_kubernetes_pod_node_name] + # separator: ; + # regex: ^(.*)$ + # targetLabel: nodename + # replacement: $1 + # action: replace + ## metric relabel configs to apply to samples before ingestion + # metricRelabelings: + # - sourceLabels: [__meta_kubernetes_service_label_cluster] + # targetLabel: cluster + # regex: (.*) + # replacement: ${1} + # action: replace + livenessProbe: enabled: true initialDelaySeconds: 10 From d399417ef65eaf71b63d2c756d07c373765cd9a9 Mon Sep 17 00:00:00 2001 From: Erhhung Yuan Date: Fri, 9 May 2025 15:32:11 -0700 Subject: [PATCH 2/3] fix(fluent-operator): Inconsistent values.yaml indentation Signed-off-by: Erhhung Yuan --- charts/fluent-operator/values.yaml | 106 ++++++++++++++--------------- 1 file changed, 52 insertions(+), 54 deletions(-) diff --git a/charts/fluent-operator/values.yaml b/charts/fluent-operator/values.yaml index d9167ca6..c6075782 100644 --- a/charts/fluent-operator/values.yaml +++ b/charts/fluent-operator/values.yaml @@ -14,7 +14,6 @@ operator: initcontainer: repository: "docker" tag: "20.10" - resources: limits: cpu: 100m @@ -128,12 +127,11 @@ fluentbit: cpu: 10m memory: 25Mi # Specify custom annotations to be added to each FluentBit pod. - annotations: - {} - ## Request to Fluent Bit to exclude or not the logs generated by the Pod. - # fluentbit.io/exclude: "true" - ## Prometheus can use this tag to automatically discover the Pod and collect monitoring data - # prometheus.io/scrape: "true" + annotations: {} + ## Request to Fluent Bit to exclude or not the logs generated by the Pod. + # fluentbit.io/exclude: "true" + ## Prometheus can use this tag to automatically discover the Pod and collect monitoring data + # prometheus.io/scrape: "true" # Specify additional custom labels for fluentbit-pods labels: {} @@ -251,18 +249,18 @@ fluentbit: pauseOnChunksOverlimit: "off" nodeExporterMetrics: {} # uncomment below nodeExporterMetrics section if you want to collect node exporter metrics - # nodeExporterMetrics: - # tag: node_metrics - # scrapeInterval: 15s - # path: - # procfs: /host/proc - # sysfs: /host/sys + # nodeExporterMetrics: + # tag: node_metrics + # scrapeInterval: 15s + # path: + # procfs: /host/proc + # sysfs: /host/sys fluentBitMetrics: {} # uncomment below fluentBitMetrics section if you want to collect fluentBit metrics -# fluentBitMetrics: -# scrapeInterval: "2" -# scrapeOnStart: true -# tag: "fb.metrics" + # fluentBitMetrics: + # scrapeInterval: "2" + # scrapeOnStart: true + # tag: "fb.metrics" # Configure the output plugin parameter in FluentBit. # You can set enable to true to output logs to the specified location. @@ -275,26 +273,26 @@ fluentbit: logstashPrefix: ks-logstash-log bufferSize: 20MB traceError: true - # logstashPrefixKey: ks-logstash-log - # suppressTypeName: "On" - # path: "" - # bufferSize: "4KB" - # index: "fluent-bit" - # httpUser: - # httpPassword: - # logstashFormat: true - # replaceDots: false - # enableTLS: false - # writeOperation: upsert - # tls: - # verify: On - # debug: 1 - # caFile: "" - # caPath: "" - # crtFile: "" - # keyFile: "" - # keyPassword: - # vhost: "" + # logstashPrefixKey: ks-logstash-log + # suppressTypeName: "On" + # path: "" + # bufferSize: "4KB" + # index: "fluent-bit" + # httpUser: + # httpPassword: + # logstashFormat: true + # replaceDots: false + # enableTLS: false + # writeOperation: upsert + # tls: + # verify: On + # debug: 1 + # caFile: "" + # caPath: "" + # crtFile: "" + # keyFile: "" + # keyPassword: + # vhost: "" kafka: enable: false brokers: "" @@ -305,15 +303,15 @@ fluentbit: # You can configure the opensearch-related configuration here stdout: enable: false - # Uncomment the following section to enable Prometheus metrics exporter. prometheusMetricsExporter: {} -# prometheusMetricsExporter: -# match: "fb.metrics" -# metricsExporter: -# host: "0.0.0.0" -# port: 2020 -# addLabels: -# app: "fluentbit" + # uncomment the following section to enable Prometheus metrics exporter + # prometheusMetricsExporter: + # match: "fb.metrics" + # metricsExporter: + # host: "0.0.0.0" + # port: 2020 + # addLabels: + # app: "fluentbit" # Loki fluentbit ClusterOutput, to be encapsulated in fluentbit config # See https://github.com/fluent/fluent-operator/blob/master/docs/plugins/fluentbit/output/loki.md @@ -370,15 +368,15 @@ fluentbit: service: storage: {} -# Remove the above storage section and uncomment below section if you want to configure file-system as storage for buffer -# storage: -# path: "/host/fluent-bit-buffer/" -# backlogMemLimit: "50MB" -# checksum: "off" -# deleteIrrecoverableChunks: "on" -# maxChunksUp: 128 -# metrics: "on" -# sync: normal + # uncomment below section if you want to configure file-system as storage for buffer + # storage: + # path: "/host/fluent-bit-buffer/" + # backlogMemLimit: "50MB" + # checksum: "off" + # deleteIrrecoverableChunks: "on" + # maxChunksUp: 128 + # metrics: "on" + # sync: normal # Configure the default filters in FluentBit. # The `filter` will filter and parse the collected log information and output the logs into a uniform format. You can choose whether to turn this on or not. From 5c92abb2180519ef2ab54bd76d6c46ed23d5a186 Mon Sep 17 00:00:00 2001 From: Erhhung Yuan Date: Sat, 10 May 2025 00:00:34 -0700 Subject: [PATCH 3/3] fix(fluent-operator): Rename to .Values.fluentbit.serviceMonitor.labels (#605) --- .../templates/fluentbit-servicemonitor.yaml | 2 +- charts/fluent-operator/values.yaml | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml b/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml index 935b025b..c3a22d67 100644 --- a/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml +++ b/charts/fluent-operator/templates/fluentbit-servicemonitor.yaml @@ -8,7 +8,7 @@ metadata: namespace: {{ template "fluent-operator.namespace" . }} labels: app.kubernetes.io/name: fluent-bit - {{- with .Values.fluentbit.serviceMonitor.selector }} + {{- with .Values.fluentbit.serviceMonitor.labels }} {{- toYaml . | nindent 4 }} {{- end }} spec: diff --git a/charts/fluent-operator/values.yaml b/charts/fluent-operator/values.yaml index c6075782..e27603e4 100644 --- a/charts/fluent-operator/values.yaml +++ b/charts/fluent-operator/values.yaml @@ -79,18 +79,16 @@ fluentbit: serviceMonitor: enable: false - ## ServiceMonitor selector labels - # selector: + ## Labels that the Prometheus Operator looks for to act on this ServiceMonitor + # labels: # release: prometheus-stack - ## additional service selector labels - # labels: {} path: /api/v2/metrics/prometheus - ## applies "scheme: https" and tlsConfig if true + ## Applies "scheme: https" and tlsConfig if true secure: false # tlsConfig: {} interval: 30s scrapeTimeout: 10s - ## relabel configs to apply to samples after ingestion + ## Relabel configs to apply to samples after ingestion # relabelings: # - sourceLabels: [__meta_kubernetes_pod_node_name] # separator: ; @@ -98,7 +96,7 @@ fluentbit: # targetLabel: nodename # replacement: $1 # action: replace - ## metric relabel configs to apply to samples before ingestion + ## Metric relabel configs to apply to samples before ingestion # metricRelabelings: # - sourceLabels: [__meta_kubernetes_service_label_cluster] # targetLabel: cluster