VictoriaMetrics/VictoriaMetrics · error

cannot parse `relabel_configs` for `job_name` %q: %w

Error message

cannot parse `relabel_configs` for `job_name` %q: %w

What it means

The merged (global + per-job) relabel_configs are compiled via promrelabel.ParseRelabelConfigs, which validates labels, regexes, and actions. Parse failures are wrapped with the job name and abort loading.

Source

Thrown at lib/promscrape/config.go:980

	}
	params := sc.Params
	ac, err := sc.HTTPClientConfig.NewConfig(baseDir)
	if err != nil {
		return nil, fmt.Errorf("cannot parse auth config for `job_name` %q: %w", jobName, err)
	}
	proxyAC, err := sc.ProxyClientConfig.NewConfig(baseDir)
	if err != nil {
		return nil, fmt.Errorf("cannot parse proxy auth config for `job_name` %q: %w", jobName, err)
	}
	rcs := sc.RelabelConfigs
	if len(globalCfg.RelabelConfigs) > 0 {
		rcs = make([]promrelabel.RelabelConfig, 0, len(globalCfg.RelabelConfigs)+len(sc.RelabelConfigs))
		rcs = append(rcs, globalCfg.RelabelConfigs...)
		rcs = append(rcs, sc.RelabelConfigs...)
	}
	relabelConfigs, err := promrelabel.ParseRelabelConfigs(rcs)
	if err != nil {
		return nil, fmt.Errorf("cannot parse `relabel_configs` for `job_name` %q: %w", jobName, err)
	}
	mrcs := sc.MetricRelabelConfigs
	if len(globalCfg.MetricRelabelConfigs) > 0 {
		mrcs = make([]promrelabel.RelabelConfig, 0, len(globalCfg.MetricRelabelConfigs)+len(sc.MetricRelabelConfigs))
		mrcs = append(mrcs, globalCfg.MetricRelabelConfigs...)
		mrcs = append(mrcs, sc.MetricRelabelConfigs...)
	}
	metricRelabelConfigs, err := promrelabel.ParseRelabelConfigs(mrcs)
	if err != nil {
		return nil, fmt.Errorf("cannot parse `metric_relabel_configs` for `job_name` %q: %w", jobName, err)
	}
	sampleLimit := sc.SampleLimit
	if sampleLimit <= 0 {
		sampleLimit = globalCfg.SampleLimit
	}
	externalLabels := globalCfg.ExternalLabels
	noStaleTracking := *noStaleMarkers
	if sc.NoStaleMarkers != nil {

View on GitHub (pinned to 5079fb58f1)

Solutions

  1. Fix the regex/action reported by the wrapped inner error for the given job_name
  2. Check each relabel_config has valid action and required source_labels/target_label
  3. Run -dryRun to see the full validation error before restart

Example fix

// before
relabel_configs:
  - source_labels: [__name__]
    regex: '(.+'
    action: replace
// after
relabel_configs:
  - source_labels: [__name__]
    regex: '(.*)'
    action: replace
Defensive patterns

Strategy: validation

Validate before calling

// Validate relabel rules compile before deploy
if _, err := promrelabel.ParseRelabelConfigs(sc.RelabelConfigs); err != nil {
	return fmt.Errorf("job %q: bad relabel_configs: %w", sc.JobName, err)
}

Try / catch

if err := promscrape.CheckConfig(); err != nil {
	logger.Fatalf("error when checking -promscrape.config: %s", err)
}

Prevention

When it happens

Trigger: A relabel_config with invalid `action`, invalid `regex` (uncompilable RE2), missing source_labels for actions that need them, or an empty `target_label` where required.

Common situations: Regex typos like '(.+' (unbalanced); unsupported action names copied from other systems; YAML lists accidentally merged so an entry is a scalar instead of a map.

Related errors


AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03). Data as JSON: /api/errors/ff7e9ba007fd7655. Report an issue: GitHub.