VictoriaMetrics/VictoriaMetrics · error

`regex` cannot be used for `action=graphite`; see https://do

Error message

`regex` cannot be used for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling

What it means

`action=graphite` uses its Graphite-template matching instead of a regular expression, so a `regex` field is not applicable. The parser rejects configs that set `regex` with `action=graphite` to avoid ambiguity about which matcher applies.

Source

Thrown at lib/promrelabel/config.go:278

	switch action {
	case "graphite":
		if graphiteMatchTemplate == nil {
			return nil, fmt.Errorf("missing `match` for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling")
		}
		if len(graphiteLabelRules) == 0 {
			return nil, fmt.Errorf("missing `labels` for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling")
		}
		if len(rc.SourceLabels) > 0 {
			return nil, fmt.Errorf("`source_labels` cannot be used with `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling")
		}
		if rc.TargetLabel != "" {
			return nil, fmt.Errorf("`target_label` cannot be used with `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling")
		}
		if rc.Replacement != nil {
			return nil, fmt.Errorf("`replacement` cannot be used with `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling")
		}
		if rc.Regex != nil {
			return nil, fmt.Errorf("`regex` cannot be used for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling")
		}
	case "replace":
		if targetLabel == "" {
			return nil, fmt.Errorf("missing `target_label` for `action=replace`")
		}
	case "replace_all":
		if len(sourceLabels) == 0 {
			return nil, fmt.Errorf("missing `source_labels` for `action=replace_all`")
		}
		if targetLabel == "" {
			return nil, fmt.Errorf("missing `target_label` for `action=replace_all`")
		}
	case "keep_if_contains":
		if targetLabel == "" {
			return nil, fmt.Errorf("`target_label` must be set for `action=keep_if_contains`")
		}
		if len(sourceLabels) == 0 {
			return nil, fmt.Errorf("`source_labels` must contain at least a single entry for `action=keep_if_contains`")

View on GitHub (pinned to 5079fb58f1)

Solutions

  1. Remove the `regex` field from the graphite relabel entry
  2. Move any needed matching into the graphite `template`
  3. Switch the action to `replace`/`replace_all` if regex matching is required

Example fix

// before
- action: graphite
  regex: "(.*)"
  template: <metric_name>.<label_name>=<label_value>
// after
- action: graphite
  template: <metric_name>.<label_name>=<label_value>
Defensive patterns

Strategy: validation

Validate before calling

def validate_relabel(cfg):
    if cfg.get('action') == 'graphite' and cfg.get('regex') is not None:
        raise ValueError('regex cannot be used with action=graphite')
    return True

Prevention

When it happens

Trigger: ParseRelabelConfigs (or newTestRegexRelabelConfig) is given a config with `action: graphite` and a non-nil `regex` field.

Common situations: Copy-pasting a `replace` rule and only changing the action to `graphite`; generators that always emit `regex: (.*)` for relabel rules.

Related errors


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