prometheus/node_exporter · error

fail to compile --collector.cpu.info.flags-include and…

Error message

fail to compile --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include, the values of them must be regular expressions: %w

What it means

When --collector.cpu.info is enabled, the cpu collector compiles the --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include values as regular expressions used to filter reported CPU flags/bugs. If either value is not a valid Go regexp, compilation fails at collector construction and node_exporter exits with this wrapped error.

Solutions

  1. Validate the expressions with Go regexp syntax (test with `go` or any RE2-compatible checker) and fix the syntax
  2. Remember these are regexes, not globs: use 'avx.*' not 'avx*'
  3. Escape properly in your shell/systemd unit (double backslashes where needed)
  4. Unset the flags or disable --collector.cpu.info if filtering is not required

Example fix

// before
--collector.cpu.info.flags-include='avx*'       // glob, invalid regex
// after
--collector.cpu.info.flags-include='^avx.*$'
Defensive patterns

Strategy: validation

Validate before calling

// Go: validate the flags like the collector does, before launching
import "regexp"
func validRE(s string) bool {
    if s == "" { return true }
    _, err := regexp.Compile(s)
    return err == nil
}
// usage: if !validRE(*flagsInclude) || !validRE(*bugsInclude) { flag.Usage(); os.Exit(2) }

Try / catch

if err := startExporter(args); err != nil && strings.Contains(err.Error(), "must be regular expressions") {
    return fmt.Errorf("fix --collector.cpu.info.flags-include/--bugs-include (RE2 syntax): %w", err)
}

Prevention

When it happens

Trigger: compileIncludeFlags returns an error because flagsInclude or bugsInclude contains invalid regexp syntax (e.g. unbalanced parentheses, bad escape sequences like \p{x} or stray '*').

Common situations: Operators paste shell glob patterns (e.g. 'avx*') or fragmented regexes into the flags; quoting issues in systemd units strip backslashes; using PCRE-only syntax unsupported by Go's RE2 (e.g. lookaheads).

Related errors


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/57b121c8bf89dc3b. Report an issue: GitHub.

Appendix: source

Thrown at collector/cpu_linux.go:148

			[]string{"package"}, nil,
		),
		cpuIsolated: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "isolated"),
			"Whether each core is isolated, information from /sys/devices/system/cpu/isolated.",
			[]string{"cpu"}, nil,
		),
		cpuOnline: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "online"),
			"CPUs that are online and being scheduled.",
			[]string{"cpu"}, nil,
		),
		logger:       logger,
		isolatedCpus: isolcpus,
		cpuStats:     make(map[int64]procfs.CPUStat),
	}
	err = c.compileIncludeFlags(flagsInclude, bugsInclude)
	if err != nil {
		return nil, fmt.Errorf("fail to compile --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include, the values of them must be regular expressions: %w", err)
	}
	return c, nil
}

func (c *cpuCollector) compileIncludeFlags(flagsIncludeFlag, bugsIncludeFlag *string) error {
	if (*flagsIncludeFlag != "" || *bugsIncludeFlag != "") && !*enableCPUInfo {
		*enableCPUInfo = true
		c.logger.Info("--collector.cpu.info has been set to `true` because you set the following flags, like --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include")
	}

	var err error
	if *flagsIncludeFlag != "" {
		c.cpuFlagsIncludeRegexp, err = regexp.Compile(*flagsIncludeFlag)
		if err != nil {
			return err
		}
	}
	if *bugsIncludeFlag != "" {

View on GitHub (pinned to 17ddd77c59)