thanos-io/thanos · error

initializing the labels cache config

Error message

initializing the labels cache config

What it means

Identical to the query-range cache failure but for the labels cache: errors from queryfrontend.NewCacheConfig on the labels cache YAML (via --labels-cache-config-file or inline content) are wrapped with this message. It means the labels cache backend configuration could not be built.

Solutions

  1. Read the wrapped underlying error to find the offending key.
  2. Ensure backend type is supported and required options (e.g. memcached addresses) are set.
  3. Validate the YAML against the CacheConfig schema for the Thanos version in use.
  4. Decouple the two configs: fix the labels cache YAML separately from the query-range cache YAML.

Example fix

// before
type: memcached
// after
type: memcached
memcached:
  addresses: [dnssrvnoa+memcached:11211]
Defensive patterns

Strategy: validation

Validate before calling

if !backendKnown(labelsCacheYAML) {
  return errors.New("labels cache config: unknown or missing backend type")
}

Try / catch

if _, err := queryfrontend.NewCacheConfig(logger, labelsCacheYAML); err != nil {
  log.Fatalf("labels cache config invalid: %v", err)
}

Prevention

When it happens

Trigger: Providing a labels cache config YAML with an invalid backend type, missing memcached/redis options, wrong field types, or malformed YAML.

Common situations: Copy-pasting the query-range cache YAML into the labels cache flag with fields the schema rejects, or leaving default example content with placeholder addresses.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/65138bc395e5db9e. Report an issue: GitHub.

Appendix: source

Thrown at cmd/thanos/query_frontend.go:294

		cacheConfig, err := queryfrontend.NewCacheConfig(logger, queryRangeCacheConfContentYaml)
		if err != nil {
			return errors.Wrap(err, "initializing the query range cache config")
		}
		cfg.QueryRangeConfig.ResultsCacheConfig = &queryrange.ResultsCacheConfig{
			Compression:                cfg.CacheCompression,
			CacheConfig:                *cacheConfig,
			CacheQueryableSamplesStats: cfg.CortexHandlerConfig.QueryStatsEnabled,
		}
	}

	labelsCacheConfContentYaml, err := cfg.LabelsConfig.CachePathOrContent.Content()
	if err != nil {
		return err
	}
	if len(labelsCacheConfContentYaml) > 0 {
		cacheConfig, err := queryfrontend.NewCacheConfig(logger, labelsCacheConfContentYaml)
		if err != nil {
			return errors.Wrap(err, "initializing the labels cache config")
		}
		cfg.LabelsConfig.ResultsCacheConfig = &queryrange.ResultsCacheConfig{
			Compression: cfg.CacheCompression,
			CacheConfig: *cacheConfig,
		}
	}

	if err := cfg.Validate(); err != nil {
		return errors.Wrap(err, "error validating the config")
	}

	if cfg.EnableXFunctions {
		maps.Copy(parser.Functions, parse.XFunctions)
	}

	if len(cfg.EnableFeatures) > 0 {
		for _, feature := range cfg.EnableFeatures {
			if feature == promqlExperimentalFunctions {

View on GitHub (pinned to 35b8b99117)