Repository navigation
feat: allow overriding metrics-exporter log verbosity via env (#1793) - #2131
Conversation
Add CHOP_LOGGER_* env vars (LOGTOSTDERR, ALSOLOGTOSTDERR, STDERRTHRESHOLD, V, VMODULE, LOG_BACKTRACE_AT) that override the matching logger.* options of the operator configuration in the process they are set for. This lets the metrics-exporter use its own verbosity while sharing the config file with the operator. Helm: add metrics.logVerbosity (empty by default), rendered as CHOP_LOGGER_V into the metrics-exporter container only. Fixes #1793 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1699d9e to
35803ee
Compare
|
Why is it needed? Would it be better to use operator configuration? |
|
@alex-zaitsev for example we need to debug metrics-exporter but don't need increase verbosity for clickhouse-operator, and invariant - debug clickhouse-operator and don't increase logs verbosiry for metrics-exporter |
|
@alex-zaitsev operator configuration can't do this: both The original request in #1793 is to reduce metrics-exporter log noise (with |
|
Helm example, different logging for operator and metrics-exporter: configs:
files:
config.yaml:
logger:
v: "3" # default for both containers
operator:
env:
- name: CHOP_LOGGER_VMODULE
value: "worker*=5"
metrics:
logVerbosity: 0 # CHOP_LOGGER_V for metrics-exporter only
env:
- name: CHOP_LOGGER_VMODULE
value: "exporter=2" |
Render operator.logVerbosity as CHOP_LOGGER_V into the clickhouse-operator container only, symmetric to metrics.logVerbosity, so operator and metrics-exporter verbosity can be set independently via helm values. Refs #1793 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fixes #1793
Problem
The operator and the metrics-exporter read the same configuration file, and
chop.SetupLog()applieslogger.*from it viaflag.Set, overwriting the-vpassed on the command line. So there was no way to make the metrics-exporter quieter (or more verbose) without changing the operator's logging too, short of replacing the whole config or overriding container args.Design
Precedence: config file
logger.*value, overridden by an env var when set (non-empty). This is the first step of theconfig file -> env vars -> CLI paramsdirection suggested in the issue, scoped to logger options.pkg/apis/deployment/env_vars.go, one perlogger.*option:CHOP_LOGGER_LOGTOSTDERR,CHOP_LOGGER_ALSOLOGTOSTDERR,CHOP_LOGGER_STDERRTHRESHOLD,CHOP_LOGGER_V,CHOP_LOGGER_VMODULE,CHOP_LOGGER_LOG_BACKTRACE_AT.SetupLog()is now table-driven and applies the env value over the config value. Behavior with no env vars set is unchanged.metrics.logVerbosityvalue (empty by default), rendered asCHOP_LOGGER_Vinto the metrics-exporter container only (via a_helpers.tplinclude;0is handled as a valid value). It is rendered beforemetrics.env, so an explicitmetrics.enventry still wins. The generated Deployment template is produced bydev/generate_helm_chart.sh, which was updated accordingly;values.schema.jsonand the helm-docs README are updated.docs/operator_configuration.md.Usage
Helm:
Plain manifest, in the
metrics-exportercontainer:Tests
pkg/chop/setup_log_test.go: env overrides config value; options without env keep config value; env applies when config is empty; empty env does not override.go build ./...go test -vet=off -race -count=1 ./pkg/chop/... ./pkg/apis/...- passgo vet -copylocks=false -printf=false ./pkg/chop/... ./pkg/apis/deployment/...- passhelm templatewith no value (no env rendered),logVerbosity=0,--set-string logVerbosity=3,null, and together withmetrics.env;helm lint;dev/test_helm_chart.sh- 24 checks passed.