Skip to content

feat: set Alias on auto-generated namespace-routing rewrite_tag filters - #2052

Open
ruben-chainalysis wants to merge 2 commits into
fluent:masterfrom
ruben-chainalysis:feat/rewrite-tag-alias
Open

feat: set Alias on auto-generated namespace-routing rewrite_tag filters#2052
ruben-chainalysis wants to merge 2 commits into
fluent:masterfrom
ruben-chainalysis:feat/rewrite-tag-alias

Conversation

@ruben-chainalysis

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Auto-generated namespace-routing rewrite_tag filters (created by generateRewriteTagConfig) produce metrics with opaque names like rewrite_tag.0, rewrite_tag.1. This makes it impossible to correlate filter pipeline metrics (fluentbit_filter_records, fluentbit_filter_emit_records) back to the namespace they route for.

This PR sets Alias on each auto-generated rewrite_tag filter using the pattern namespace-routing-<namespace>, so filter metrics become identifiable (e.g. namespace-routing-kube-system instead of rewrite_tag.3).

FluentBit core already uses Alias as the name label in Prometheus metrics (fluent/fluent-bit#4694). CRD-defined filters already support Alias (#356, #370). After #2019 refactored generateRewriteTagConfig to use a filter.RewriteTag struct, CommonParams.AddCommonParams() handles emission, so this is a one-field addition.

Alias uniqueness is guaranteed because Kubernetes namespace names are unique per cluster, so namespace-routing-<ns> cannot collide (fluent/fluent-bit#6076 does not apply).

Which issue(s) this PR fixes:

Fixes #2051

Does this PR introduced a user-facing change?

Auto-generated namespace-routing rewrite_tag filters now set Alias to `namespace-routing-<namespace>`, making filter metrics identifiable by namespace.

Additional documentation, usage docs, etc.:

None

The auto-generated rewrite_tag filter used for namespace routing did not
set the Alias field, causing Fluent Bit filter metrics to report opaque
names like rewrite_tag.0 instead of meaningful identifiers.

Set Alias to "namespace-routing-<namespace>" unconditionally so that
each FluentBitConfig's rewrite_tag filter is distinguishable in metrics.
The value is derived from the config's namespace (always available) and
does not require any CRD schema changes.

Fixes: fluent#2051
Signed-off-by: Rubén Cabrera Martínez <ruben.cabrera@chainalysis.com>
Signed-off-by: Rubén Cabrera Martínez <ruben.cabrera@chainalysis.com>
@ruben-chainalysis

Copy link
Copy Markdown
Contributor Author

I didn't find the right place to document this, but always happy to put some docs in my PR if you help me with it.

As I said in the linked issue, I don't have an opinion about the naming convention for the Alias, just used the first thing that came to mind. Would putting the namespace name first help for things like dashboard fonts not fitting a very long name? That way the least relevant part of the alias goes at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Named namespace-routing rewrite_tag filters

1 participant