thanos-io/thanos · error

failed to initialize config watcher

Error message

failed to initialize config watcher

What it means

receive.NewConfigWatcher failed while initializing the hashring file watcher, e.g. the --hashrings-file path does not exist or is unreadable. Without the watcher receive cannot learn hashring updates.

Solutions

  1. Verify --hashrings-file points to an existing readable file
  2. Check file permissions and mount availability
  3. Validate the hashring file content separately
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cmd/thanos/receive.go:604 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at cmd/thanos/receive.go:604

	conf *receiveConfig,
	hashringChangedChan chan struct{},
	webHandler *receive.Handler,
	statusProber prober.Probe,
	enableIngestion bool,
	dbs *receive.MultiTSDB,
) error {
	// Note: the hashring configuration watcher
	// is the sender and thus closes the chan.
	// In the single-node case, which has no configuration
	// watcher, we close the chan ourselves.
	updates := make(chan []receive.HashringConfig, 1)
	algorithm := receive.HashringAlgorithm(conf.hashringsAlgorithm)

	// The Hashrings config file path is given initializing config watcher.
	if conf.hashringsFilePath != "" {
		cw, err := receive.NewConfigWatcher(log.With(logger, "component", "config-watcher"), reg, conf.hashringsFilePath, *conf.refreshInterval)
		if err != nil {
			return errors.Wrap(err, "failed to initialize config watcher")
		}

		// Check the hashring configuration on before running the watcher.
		if err := cw.ValidateConfig(); err != nil {
			cw.Stop()
			close(updates)
			return errors.Wrap(err, "failed to validate hashring configuration file")
		}

		ctx, cancel := context.WithCancel(context.Background())
		g.Add(func() error {
			return receive.ConfigFromWatcher(ctx, updates, cw)
		}, func(error) {
			cancel()
		})
	} else {
		var (
			cf  []receive.HashringConfig

View on GitHub (pinned to 35b8b99117)