querier: preserve UTF-8 (dotted) label names on read when sanitization is disabled#2
Open
1linkovdim wants to merge 1 commit into
Conversation
…n is disabled Dotted label names (e.g. nf.app) are stored and matchable when the operator runs with validation.disable-label-sanitization=true, but they were still filtered out of LabelNames/Series label listings (and therefore Grafana typeahead) unless the request carried the per-request allow-utf8-labelnames client capability. In the v1 read path that capability never reaches the querier: it is parsed by the query-frontend HTTP middleware, but querier.NewGRPCHandler does not re-apply ClientCapabilitiesHttpMiddleware and the capability is not propagated over the frontend->querier hop. So dotted label names are unconditionally dropped from listings on v1, even though they can be queried by matcher. Preserve them additionally whenever label sanitization is disabled for the tenant. That is the same setting that keeps dotted names verbatim on the write path, so honoring it on read makes read symmetric with write and works for every client (including the Grafana datasource query editor and dashboard variables, which never send the capability). The per-request capability behavior is preserved unchanged. Adds Querier.keepUTF8LabelNames() and unit tests covering the capability, the disable-label-sanitization limit, and the no-tenant case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
We add standard Netflix infrastructure labels (
nf.app,nf.region, …) to exported profiles. Withvalidation.disable-label-sanitization=true(our config), Pyroscope stores these dotted label names verbatim and they're matchable —{"nf.app"="foo"}works. But they never appear in Grafana typeahead / label listings.Root cause
LabelNames(and theSerieslabel filter) drop any label name failing legacy Prometheus validation — i.e. anything with a.— unless the request carries the per-requestallow-utf8-labelnamesclient capability.In the v1 read path (
-architecture.storage=v1) that capability never reaches the querier, where the filter runs:querier.NewGRPCHandler(pkg/querier/grpc_handler.go) wraps the QuerierService mux with only K6 middleware — notClientCapabilitiesHttpMiddleware.So
GetClientCapabilities(ctx)is always!okin the querier, and dotted names are unconditionally filtered from listings — even though they're stored and queryable. Verified against prod:LabelValuesfornf.appreturns 2200 values, butLabelNames(even with a correctly-formed capability header sent to the query-frontend) omits it.Fix
Preserve non-legacy label names on read whenever label sanitization is disabled for the tenant — the same setting that keeps them verbatim on the write path. This makes read symmetric with write and works for every client (Grafana datasource query editor, dashboard variables, Drilldown, profilecli), none of which need to send the capability. The existing per-request capability behavior is preserved unchanged.
Querier.keepUTF8LabelNames(ctx): true if the request carries the capability orDisableLabelSanitization(tenant)is set.LabelNamesfilter sites and theSerieslabel filter to use it.DisableLabelSanitization(string) boolto the querierLimitsinterface (validation.Overridesalready implements it).Tests
pkg/querier/querier_utf8_labels_test.go— covers: sanitization-disabled preserves dotted names without a capability; sanitization-enabled filters without a capability; capability preserves regardless; no-tenant falls back to filtering.go test ./pkg/querier/+go vetpass.Scope / notes
disable-label-sanitizationis already true (cluster-wide for us viaoverrides: {}).pkg/frontend/readpath/queryfrontend/) for completeness.🤖 Generated with Claude Code