Skip to content

Fix metrics generator panic when write_relabel_configs is set - #6399

Merged
carles-grafana merged 1 commit into
grafana:mainfrom
carles-grafana:fix_config_panic
Feb 6, 2026
Merged

Fix metrics generator panic when write_relabel_configs is set #6399
carles-grafana merged 1 commit into
grafana:mainfrom
carles-grafana:fix_config_panic

Conversation

@carles-grafana

@carles-grafana carles-grafana commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

What this PR does:

Fix metrics generator panic when write_relabel_configs is set (#6396)

The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR
prometheus/prometheus#16928) moved label name validation from a global
to a per-config NameValidationScheme field on relabel.Config. This field
must be initialized by calling Validate() before use, otherwise
relabeling panics with "Invalid name validation scheme requested: unset".

Tempo constructs RemoteWriteConfig programmatically rather than going
through Prometheus's config.Load() path, so Validate() was never called.

Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup
in storage.Config.Validate(), which initializes NameValidationScheme on
all write relabel configs before any tenant storage instances are created.

Also fix a pre-existing bug in watchOverrides where cached state was
updated before ApplyConfig succeeded, preventing retries on failure.

Which issue(s) this PR fixes:
Fixes #6396

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@carles-grafana
carles-grafana force-pushed the fix_config_panic branch 2 times, most recently from 3610c5d to 82e7dcc Compare February 6, 2026 10:17
@carles-grafana carles-grafana changed the title wiup Fix metrics generator panic when write_relabel_configs is set Feb 6, 2026
@carles-grafana
carles-grafana marked this pull request as ready for review February 6, 2026 10:27
// mutate the shared input configs. Without this, concurrent
// watchOverrides goroutines from different tenants would race on
// the shared *relabel.Config objects.
output.WriteRelabelConfigs = copyRelabelConfigs(input.WriteRelabelConfigs)

@javiermolinar javiermolinar Feb 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think the deep copy is needed here if we validate the base config once at startup. cfg.RemoteWrite is global (not tenant-specific), so we can initialize/validate its relabel configs when the metrics generator starts.

In generateTenantRemoteWriteConfigs, we only inject per-tenant headers. Doing validation once would simplify this path and avoid per-tenant allocations. Per-tenant path should just clone config as it is right now and inject headers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. The whole issue was that the Validate from Prometheus sets one field: https://github.com/carles-grafana/tempo/blob/fix_config_panic/vendor/github.com/prometheus/prometheus/model/relabel/relabel.go#L135

by moving it to startup it's much simpler. fixed

…a#6396)

  The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR
  prometheus/prometheus#16928) moved label name validation from a global
  to a per-config NameValidationScheme field on relabel.Config. This field
  must be initialized by calling Validate() before use, otherwise
  relabeling panics with "Invalid name validation scheme requested: unset".

  Tempo constructs RemoteWriteConfig programmatically rather than going
  through Prometheus's config.Load() path, so Validate() was never called.

  Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup
  in storage.Config.Validate(), which initializes NameValidationScheme on
  all write relabel configs before any tenant storage instances are created.

  Also fix a pre-existing bug in watchOverrides where cached state was
  updated before ApplyConfig succeeded, preventing retries on failure.

@javiermolinar javiermolinar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Have you tested it with our docker example?

@carles-grafana

Copy link
Copy Markdown
Contributor Author

yes, tested with docker successfully

@carles-grafana
carles-grafana merged commit 98ed8a8 into grafana:main Feb 6, 2026
23 checks passed
carles-grafana added a commit that referenced this pull request Feb 13, 2026
…#6399)

The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR
  prometheus/prometheus#16928) moved label name validation from a global
  to a per-config NameValidationScheme field on relabel.Config. This field
  must be initialized by calling Validate() before use, otherwise
  relabeling panics with "Invalid name validation scheme requested: unset".

  Tempo constructs RemoteWriteConfig programmatically rather than going
  through Prometheus's config.Load() path, so Validate() was never called.

  Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup
  in storage.Config.Validate(), which initializes NameValidationScheme on
  all write relabel configs before any tenant storage instances are created.

  Also fix a pre-existing bug in watchOverrides where cached state was
  updated before ApplyConfig succeeded, preventing retries on failure.
carles-grafana added a commit that referenced this pull request Feb 16, 2026
…#6399) (#6455)

The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR
  prometheus/prometheus#16928) moved label name validation from a global
  to a per-config NameValidationScheme field on relabel.Config. This field
  must be initialized by calling Validate() before use, otherwise
  relabeling panics with "Invalid name validation scheme requested: unset".

  Tempo constructs RemoteWriteConfig programmatically rather than going
  through Prometheus's config.Load() path, so Validate() was never called.

  Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup
  in storage.Config.Validate(), which initializes NameValidationScheme on
  all write relabel configs before any tenant storage instances are created.

  Also fix a pre-existing bug in watchOverrides where cached state was
  updated before ApplyConfig succeeded, preventing retries on failure.
mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
…a#6396) (grafana#6399)

The Prometheus dependency upgrade from v0.304.2 to v0.307.3 (PR
  prometheus/prometheus#16928) moved label name validation from a global
  to a per-config NameValidationScheme field on relabel.Config. This field
  must be initialized by calling Validate() before use, otherwise
  relabeling panics with "Invalid name validation scheme requested: unset".

  Tempo constructs RemoteWriteConfig programmatically rather than going
  through Prometheus's config.Load() path, so Validate() was never called.

  Call RemoteWriteConfig.Validate(model.UTF8Validation) once at startup
  in storage.Config.Validate(), which initializes NameValidationScheme on
  all write relabel configs before any tenant storage instances are created.

  Also fix a pre-existing bug in watchOverrides where cached state was
  updated before ApplyConfig succeeded, preventing retries on failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metrics generator crash in 2.10.0

2 participants