{"record":{"id":"c743bee617aea21b","repo":"VictoriaMetrics/VictoriaMetrics","slug":"regex-cannot-be-used-for-action-graphite-see","errorCode":null,"errorMessage":"`regex` cannot be used for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling","messagePattern":"`regex` cannot be used for `action=graphite`; see https://docs\\.victoriametrics\\.com/victoriametrics/vmagent/#graphite-relabeling","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/promrelabel/config.go","lineNumber":278,"sourceCode":"\tswitch action {\n\tcase \"graphite\":\n\t\tif graphiteMatchTemplate == nil {\n\t\t\treturn nil, fmt.Errorf(\"missing `match` for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling\")\n\t\t}\n\t\tif len(graphiteLabelRules) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"missing `labels` for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling\")\n\t\t}\n\t\tif len(rc.SourceLabels) > 0 {\n\t\t\treturn nil, fmt.Errorf(\"`source_labels` cannot be used with `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling\")\n\t\t}\n\t\tif rc.TargetLabel != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"`target_label` cannot be used with `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling\")\n\t\t}\n\t\tif rc.Replacement != nil {\n\t\t\treturn nil, fmt.Errorf(\"`replacement` cannot be used with `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling\")\n\t\t}\n\t\tif rc.Regex != nil {\n\t\t\treturn nil, fmt.Errorf(\"`regex` cannot be used for `action=graphite`; see https://docs.victoriametrics.com/victoriametrics/vmagent/#graphite-relabeling\")\n\t\t}\n\tcase \"replace\":\n\t\tif targetLabel == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"missing `target_label` for `action=replace`\")\n\t\t}\n\tcase \"replace_all\":\n\t\tif len(sourceLabels) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"missing `source_labels` for `action=replace_all`\")\n\t\t}\n\t\tif targetLabel == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"missing `target_label` for `action=replace_all`\")\n\t\t}\n\tcase \"keep_if_contains\":\n\t\tif targetLabel == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"`target_label` must be set for `action=keep_if_contains`\")\n\t\t}\n\t\tif len(sourceLabels) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"`source_labels` must contain at least a single entry for `action=keep_if_contains`\")","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/promrelabel/config.go#L260-L296","documentation":"`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.","triggerScenarios":"ParseRelabelConfigs (or newTestRegexRelabelConfig) is given a config with `action: graphite` and a non-nil `regex` field.","commonSituations":"Copy-pasting a `replace` rule and only changing the action to `graphite`; generators that always emit `regex: (.*)` for relabel rules.","solutions":["Remove the `regex` field from the graphite relabel entry","Move any needed matching into the graphite `template`","Switch the action to `replace`/`replace_all` if regex matching is required"],"exampleFix":"// before\n- action: graphite\n  regex: \"(.*)\"\n  template: <metric_name>.<label_name>=<label_value>\n// after\n- action: graphite\n  template: <metric_name>.<label_name>=<label_value>","handlingStrategy":"validation","validationCode":"def validate_relabel(cfg):\n    if cfg.get('action') == 'graphite' and cfg.get('regex') is not None:\n        raise ValueError('regex cannot be used with action=graphite')\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put matching logic into the graphite template, not regex","Avoid generators that emit regex: (.*) unconditionally","Dry-run configs before reload"],"tags":["promrelabel","config-validation","relabeling","victoriametrics"],"backgroundTag":"invalid-relabel-config","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}