affo commented on code in PR #2711:
URL: https://github.com/apache/fluss/pull/2711#discussion_r2945120718
##########
helm/templates/_helpers.tpl:
##########
@@ -99,3 +99,20 @@ imagePullSecrets:
{{- end }}
{{- end }}
{{- end }}
+
+{{/*
+Returns a value preferring configurationOverrides over a specific key.
+Usage:
+{{ include "fluss.getWithOverride" (dict
+ "key" "some.config.key"
+ "default" .Values.some.value
+ "ctx" .) }}
+*/}}
+{{- define "fluss.getWithOverride" -}}
Review Comment:
I know that my review was pointing this out, however, I think now we are
taking 2 approaches:
- reporters -> use override
- ports -> forbid override
I am in favor of forbidding to keep an homogeneous approach.
I think this function is not needed then
##########
helm/templates/_metrics.tpl:
##########
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+{{/*
+Returns list of provided reporter names.
+*/}}
+{{- define "fluss.metrics.reporterNames" -}}
+{{- $metrics := .Values.metrics | default dict -}}
+{{- $reportersValue := (include "fluss.getWithOverride" (dict
+ "key" "metrics.reporters"
+ "default" (index $metrics "reporters" | default "")
+ "ctx" .)) | toString | trim -}}
+{{- if eq $reportersValue "" -}}
+[]
+{{- else -}}
+{{- $selected := list -}}
+{{- range $raw := regexSplit "\\s*,\\s*" $reportersValue -1 -}}
+{{- $name := trim $raw -}}
+{{- if ne $name "" -}}
+{{- $selected = append $selected $name -}}
+{{- end -}}
+{{- end -}}
+{{- $selected | toYaml -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Checks if metrics reporting is enabled, with any one of the reporters.
+*/}}
+{{- define "fluss.metrics.enabled" -}}
+{{- $reporters := include "fluss.metrics.reporterNames" . | fromYamlArray -}}
+{{- if gt (len $reporters) 0 -}}
+true
+{{- end -}}
+{{- end -}}
+
+{{/*
+Checks if a specific reporter is enabled.
+Usage:
+ {{ include "fluss.metrics.reporter.enabled" (dict "reporter" "prometheus"
"ctx" .) }}
+ {{ include "fluss.metrics.reporter.enabled" (dict "reporter" "jmx"
"ctx" .) }}
+*/}}
+{{- define "fluss.metrics.reporter.enabled" -}}
+{{- $reporterNames := include "fluss.metrics.reporterNames" .ctx |
fromYamlArray -}}
+{{- if has .reporter $reporterNames -}}
+true
+{{- end -}}
+{{- end -}}
+
+{{/*
+Checks if prometheus reporter is enabled.
+*/}}
+{{- define "fluss.metrics.reporter.prometheus.enabled" -}}
+{{- include "fluss.metrics.reporter.enabled" (dict "reporter" "prometheus"
"ctx" .) -}}
+{{- end -}}
+
+{{/*
+Checks if jmx reporter is enabled.
+*/}}
+{{- define "fluss.metrics.reporter.jmx.enabled" -}}
+{{- include "fluss.metrics.reporter.enabled" (dict "reporter" "jmx" "ctx" .)
-}}
+{{- end -}}
+
+{{/*
+Validates that each enabled reporter has a port configured.
+*/}}
+{{- define "fluss.metrics.validateReporterPorts" -}}
+{{- $metrics := .Values.metrics | default dict -}}
+{{- $reporterNames := include "fluss.metrics.reporterNames" . | fromYamlArray
-}}
+{{- range $name := $reporterNames -}}
+ {{- $reporterConfig := index $metrics $name | default dict -}}
+ {{- if not $reporterConfig.port -}}
+ {{- printf "metrics.%s.port must be set when metrics.reporters includes
%s" $name $name -}}
+ {{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Validates that reporter ports are not set via configurationOverrides.
+*/}}
+{{- define "fluss.metrics.validateNoPortOverrides" -}}
+{{- $config := .Values.configurationOverrides | default dict -}}
+{{- $reporterNames := include "fluss.metrics.reporterNames" . | fromYamlArray
-}}
+{{- range $name := $reporterNames -}}
+ {{- $portKey := printf "metrics.reporter.%s.port" $name -}}
+ {{- if hasKey $config $portKey -}}
+ {{- printf "metrics.reporter.%s.port must be set via metrics.%s.port in
values.yaml, not via configurationOverrides" $name $name -}}
+ {{- end -}}
+{{- end -}}
+{{- end -}}
+
Review Comment:
add `{{- define "fluss.metrics.validateNoReportersOverrides" -}}`
##########
website/docs/install-deploy/deploying-with-helm.md:
##########
@@ -202,6 +202,18 @@ If the internal SASL username or password is left empty,
the chart automatically
It is recommended to set these explicitly in production.
+### Metrics Parameters
+
+| Parameter | Description | Default |
+|-----------|-------------|---------|
+| `metrics.reporters` | Comma-separated reporter selector; use `""` to disable
metrics | `""` |
+| `metrics.jmx.port` | JMX reporter port range | `9250` |
+| `metrics.prometheus.port` | Prometheus reporter port | `9249` |
+| `metrics.prometheus.service.portName` | Named port exposed on metrics
services | `metrics` |
+| `metrics.prometheus.service.labels` | Additional labels added to metrics
services | `{}` |
+| `metrics.prometheus.service.annotations` | Optional annotations added to
metrics services | `{}` |
+| `metrics.reporter.<reporter>.<option>` | Configure `<option>` for
`<reporter>` (refer to the [Fluss
configuration](https://fluss.apache.org/docs/maintenance/configuration/#metrics)
| NA |
Review Comment:
this requires an update with the latest logic, we should also speak out
about the fact that some values cannot be set in the config overrides
##########
helm/templates/configmap.yaml:
##########
@@ -41,4 +41,18 @@ data:
client.security.protocol: SASL
client.security.sasl.mechanism: {{ upper $internalMechanism }}
{{- end }}
+
+ {{- end }}
+
+ {{- if include "fluss.metrics.enabled" . }}
+ ### Metrics
+
+ {{- if not (hasKey .Values.configurationOverrides "metrics.reporters") }}
Review Comment:
you won't need this once you forbid the key
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]