thanos-io/thanos · error

retrieving rule files failed. Ignoring file. pattern

Error message

retrieving rule files failed. Ignoring file. pattern %s

What it means

reloadRules expands each configured rule-file pattern with filepath.Glob. The only possible error is a syntactically bad pattern (e.g. unmatched '['); when that happens the pattern is skipped and a wrapped error "retrieving rule files failed. Ignoring file. pattern %s" is added to the error group, so the reload continues with remaining patterns but ultimately fails.

Solutions

  1. Fix the offending --rule-file glob pattern (close brackets, escape metacharacters).
  2. Quote the pattern in the shell so it isn't expanded or mangled before reaching Thanos.
  3. Test the pattern with a quick Go/Python glob or ls to confirm it matches the intended files.
  4. Check logs for the exact pattern reported in the message and correct it in the deployment manifest.

Example fix

// before
--rule-file=/etc/thanos/rules/[abc     # unclosed bracket
// after
--rule-file=/etc/thanos/rules/*.yaml
Defensive patterns

Strategy: validation

Validate before calling

// validate patterns before handing them to thanos
for pat in "$@"; do python3 -c "import glob,sys; glob.glob(sys.argv[1])" "$pat" || echo "bad pattern: $pat"; done

Prevention

When it happens

Trigger: Passing --rule-file with a malformed glob such as '/etc/rules/[abc' (unclosed bracket) or an invalid character class; ErrBadPattern from filepath.Glob.

Common situations: Shell quoting stripping or mangling brackets in the flag; templating tool emitting a partially-expanded pattern; hand-edited config with a typo in a glob.

Related errors


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

Appendix: source

Thrown at cmd/thanos/rule.go:1092

	})
}

func reloadRules(logger log.Logger,
	ruleFiles []string,
	ruleMgr *thanosrules.Manager,
	evalInterval time.Duration,
	metrics *RuleMetrics) error {
	level.Debug(logger).Log("msg", "configured rule files", "files", strings.Join(ruleFiles, ","))
	var (
		errs      errutil.MultiError
		files     []string
		seenFiles = make(map[string]struct{})
	)
	for _, pat := range ruleFiles {
		fs, err := filepath.Glob(pat)
		if err != nil {
			// The only error can be a bad pattern.
			errs.Add(errors.Wrapf(err, "retrieving rule files failed. Ignoring file. pattern %s", pat))
			continue
		}

		for _, fp := range fs {
			if _, ok := seenFiles[fp]; ok {
				continue
			}
			files = append(files, fp)
			seenFiles[fp] = struct{}{}
		}
	}

	level.Info(logger).Log("msg", "reload rule files", "numFiles", len(files))

	if err := ruleMgr.Update(evalInterval, files); err != nil {
		metrics.configSuccess.Set(0)
		errs.Add(errors.Wrap(err, "reloading rules failed"))
		return errs.Err()

View on GitHub (pinned to 35b8b99117)